Inspiration

Prediction markets get sold on a lot of trading folklore: "buy the underdog cheap," "snipe the last few seconds," "the two sides always misprice somewhere." Polymarket's 5-minute BTC Up/Down markets are the perfect place to actually test that folklore, since a new market opens and resolves every five minutes, all day, against a real live price feed. Instead of picking one trading theory and betting on it, we wanted to build something that could run a dozen competing theories side by side against the same live data and just watch which ones actually survive.

What it does

Ninefold runs nine independent, rule-based trading strategies against Polymarket's live 5-minute BTC Up/Down markets and races them head-to-head, dollar for dollar, on one dashboard.

  • Live page streams the current market end-to-end: the Chainlink price feed the market resolves against, plus the real Up/Down order book, updating with no page refresh.
  • Simulation page replays a real, recently-resolved 5-minute window tick by tick with play/pause/scrub controls, so any strategy's decisions can be studied after the fact.
  • Paper-trading leaderboard where every strategy trades an imaginary $1,000 bankroll, filling at the real ask and exiting at the real bid. The board ranks strategies by cash, tracks wins per window, and every row expands into a full trade ledger showing exactly when it bought, when it sold, and at what price.
  • Optional copy trading that connects a Polymarket account and mirrors any one strategy's trades with real money, capped at $500 a trade with an explicit confirmation step before anything goes live.

The nine strategies span underdog-buy variants, a final-seconds sniper, cross-market lag detection that watches ETH lead BTC, a regime-gated martingale, Fibonacci retracement zones, and a multi-indicator momentum score. Every strategy implements the exact same interface, so the live pipeline, the simulator, and backtests all run the identical logic with nothing special-cased.

How we built it

The whole thing is one Next.js and TypeScript app rather than a separate backend and frontend. The server owns three live connections at once: Polymarket's Gamma API for market discovery, its RTDS WebSocket for the Chainlink price feed, and its CLOB WebSocket and REST API for the live order book. It keeps an in-memory market-state store updated on every tick and pushes updates to the browser over Server-Sent Events, so the dashboard never polls.

The database stays intentionally sparse: a signal row is only written when a strategy's direction actually changes, not on every tick, through a small always-on worker process. Persistence runs on Prisma, switching automatically between local SQLite for development and a Neon Postgres database in production, with no code changes needed either way.

Challenges we ran into

Coordinating three independent real-time feeds into one consistent picture of the market was the hardest part, especially with a new market rolling over every five minutes and no room for the pipeline to fall out of sync. Getting nine genuinely different trading strategies to share one clean interface, so the exact same function could run live, in simulation, and in backtests, took real iteration. Deployment brought its own fight too, since this is a stateful, always-on WebSocket process, which rules out serverless hosting entirely and meant being deliberate about build steps, database setup, and keeping the instance always running instead of spinning down.

Accomplishments that we're proud of

Nine genuinely different trading theories running against the same live data, transparently ranked against each other with a full trade ledger for every decision, so nothing is a black box and every strategy has to earn its ranking in public.

What we learned

The biggest surprise was how much strategy performance depends on market regime rather than the strategy itself: the same underdog-buy logic that looked sharp in a choppy window looked reckless the moment BTC trended hard in one direction. Watching that shift happen live, instead of reading about it, made the case for regime-awareness far more convincingly than any backtest chart could have.

We also learned that websockets are hard. Keeping three independent live connections in sync, reconnecting cleanly when one drops without corrupting in-memory state, and handling a market rollover mid-stream every five minutes turned into some of the trickiest code in the whole project, far more than any of the actual trading logic.

What's next for Ninefold

Setting up real-money trading properly so the copy-trading feature can move beyond small test stakes, adding more strategies to the board, and backtesting across a much larger window history to get statistically meaningful win rates per strategy.

Built With

Share this project:

Updates

Submission history