Counterfactual
Bloomberg shows what happened. Counterfactual shows what happens next.
Counterfactual, demo walkthrough. Team Shipfaced.
Most broker tools are backward-looking. They show prices, positions, charts, and recent moves. Counterfactual starts from that same live broker foundation and adds a forward-looking intelligence layer on top, so an investor can see not only what a portfolio holds, but what it is secretly exposed to, and how a hypothetical shock could cascade through companies, sectors, countries, macro factors, and their own positions.
Built on the Alpaca paper-trading API during the AI Broker Hackathon, Counterfactual was the standout project of the day. The core idea is simple: a portfolio is not just a list of tickers, it is a network of assumptions. A user may think they own a diversified set of companies, but several holdings can quietly depend on the same supply chain, geography, sector, customer base, or macro condition. Counterfactual makes those hidden dependencies visible and lets the user stress-test them before the market does.
The problem it solves
Portfolio risk is often hidden in second-order dependencies. A book can look diversified by ticker count or sector label while still resting on one fragile shared assumption. Cloud companies, chip designers, foundries, semiconductor-equipment makers, and AI-infrastructure names may all react to the same disruption in Taiwan or the semiconductor supply chain.
Traditional broker dashboards usually surface this only after prices move. Counterfactual is designed to surface it earlier, by asking a sharper set of questions: which holdings are connected through the same hidden dependency, how could a shock propagate through the portfolio, which positions are most exposed, and how fragile is the book to a single shared point of failure.
The signature demo: a shock to Taiwan
The flagship scenario is a Taiwan supply-chain disruption. Starting from a connected Alpaca paper account with a live portfolio, the user runs a counterfactual shock against Taiwan and watches the cascade move through the portfolio's dependency network, tracing exposure through names and themes such as TSMC, Nvidia, ASML, cloud infrastructure, AI capex, and related semiconductor dependencies.
The app then shows the estimated portfolio impact, the most affected holdings, a 0 to 100 fragility score, the top hidden shared dependency, a visual chain of how the shock travels from the original event to portfolio-level risk, and a geographic world-map view of exposed companies and transmission paths. Finally, the AI agent proposes a possible hedge or trim, which requires human confirmation before any paper order is placed. This is the central product moment: the portfolio looks like a list of stocks, and Counterfactual reveals the network underneath.
What is under the hood
Counterfactual combines several connected surfaces into one coherent product, rather than a single trick.
A working paper-broker terminal with account value, buying power, positions, day and unrealized P/L, intraday and one-month charts, a live price strip, a ticker tape, crypto snapshots, an order ticket, and an orders table.
Maps the portfolio onto a dependency network and answers "what happens if X changes?" across scenarios like a Taiwan disruption, export-control pressure, an AI-capex slowdown, or higher-for-longer rates.
Visualizes the scenario as a causal graph. The shock starts at a node and moves step by step through related nodes, so the cascade is legible rather than just numeric.
Plots company headquarters and shock origins with curved transmission arcs, sized and colored by impact, making global exposure intuitive when it is not obvious from ticker symbols.
Detects shared non-obvious dependencies and condenses them into a 0 to 100 fragility score, a fast read on how concentrated the book is around its largest hidden dependency.
Reads the account, positions, and exposure analysis, answers natural-language questions, and proposes a hedge or trim. It never trades automatically: the user must confirm before anything reaches Alpaca.
A newspaper-style intelligence feed that runs each headline through the same engine and returns estimated impact, most-exposed holdings, and the likely transmission path for your book.
A plain-English methodology view, compliance-safe scenario explanations, and a print-ready intelligence brief that captures the scenario, impact, affected holdings, and narrative summary.
Built responsibly
Counterfactual was built as a research and education product on Alpaca paper trading. It is not financial advice and does not claim to predict the future. The product deliberately uses language like hypothetical scenario, estimated impact, dependency exposure, research only, and paper account.
Why it won
Counterfactual went beyond the baseline broker requirements. It did not stop at account connection, market data, order entry, and an LLM chat box. It combined those into a single product thesis.
Every feature reinforced that idea. The terminal proved it was a real broker surface. The graph made hidden dependencies visible. The world map made global exposure intuitive. The fragility score condensed complexity into a decision signal. The AI agent translated risk into possible action. The intelligence feed turned news into portfolio-specific impact. The export brief made the analysis shareable. And the compliance layer kept the whole thing framed responsibly.
The stack
Counterfactual is built with Next.js, React, and TypeScript, styled with Tailwind CSS. It uses the Alpaca paper Trading and Market Data APIs, with Anthropic Claude powering the AI hedging agent. The dependency graph is rendered with React Flow, the world map with d3-geo and TopoJSON, and the portfolio and market charts with Recharts, with Zustand for client-side state and Framer Motion for interaction polish. API credentials stay server-side, with external calls routed through backend handlers so secrets are never exposed in the browser.
The team: Shipfaced
Counterfactual was built by five people over the course of the hackathon.
Counterfactual was built at the AI Broker Hackathon, hosted by Quant Competitions in partnership with Alpaca, Lovable, and bunq. Featured with the team's permission.