Backtesting9 min read
How to Backtest Prediction-Market Strategies on Polymarket & Kalshi
Backtesting a prediction market is not backtesting a stock. The contracts settle to $0 or $1, the windows are minutes long, and the book is thin near the close. Here's how to do it honestly.
To backtest a prediction-market strategy honestly you replay the recorded order book each market would have traded against, size every fill against the liquidity that was genuinely resting there, and settle each position at the real $0/$1 outcome. On DepthFeed you can do this two ways — no-code in the Backtest Lab, or over the data API in your own stack — and then forward-test the survivor on live books with paper trading.
What makes prediction markets different to backtest
A prediction-market contract is not a stock or a perp. Each outcome is quoted 0 to 1 — its implied probability — and at settlement one side is worth exactly $1 and the other $0. Crypto up/down markets settle in 5 to 60 minutes against a reference price, spreads widen and depth thins into the close, and the whole life of a market can be shorter than a single candle on a normal chart.
That shape changes what a backtest needs. Sampling a last price once a minute misses most of a five-minute market; ignoring the book hides the spread that decides your P&L on a contract that pays at most a dollar; and mislabeling the settlement flips winners into losers. The rest of this guide is about getting each of those right.
Step 1 — Start from the real order book
A backtest can only be as honest as its data. Start from recorded full-depth books, then inspect each venue's stored cadence, timestamps and gaps. Short-dated markets need enough observations to support the fill assumptions; an archive does not prove what happened between its recorded observations.
DepthFeed serves stored full-depth observations for both venues. Polymarket ingestion follows CLOB updates, while recorded cadence and timestamp meaning vary by venue and endpoint. Use the documented REST fields and nullable underlying references, and validate the loader against each venue.
Step 2 — Model fills against depth, not the mid
This is the step that separates a backtest you can trade on from one that lies. A marketable order walks the book — it fills the best level first, then the next, so its average price is worse than the touch whenever it consumes more than the top level. A resting order joins the queue and only fills if the market trades through its price with enough size behind it. Filling everything at the mid with zero slippage, the default of most casual backtests, systematically overstates edge.
Whichever route you take, insist on a depth-aware fill. On a four-cent round-trip spread, on a contract that pays at most a dollar, the difference between a mid fill and a real one is enormous — and it compounds over every trade.
Step 3 — Settle at the real outcome
Because the payoff is binary, settlement is not a rounding detail — it is most of the P&L. Polymarket up/down markets resolve against a 'price to beat' set at the open versus the final reference at the close; Kalshi contracts settle yes/no against a published reference price at expiry. Backtest against the real resolution, not an assumption, and sanity-check the split: across the settled crypto up/down markets we've captured, outcomes land near a coin-flip, so any backtest whose settlement skews far from that is probably mislabeling winners.
Step 4 — Pick your workflow: no-code or API
There are two ways to run all of the above on DepthFeed. The no-code path is the Backtest Lab: pick a coin and window, choose a preset or write a short rule, select a fill model, and it replays resolved markets and settles them for you in the browser — depth-aware VWAP fills included, no pipeline to build.
The API path is for custom research at scale: pull stored full-depth observations over REST and run your model in your own stack. Live WebSocket frames and historical REST responses have distinct documented contracts. Reuse strategy logic after validating the identifiers, timestamps and field mappings for each input.
Step 5 — Forward-test before you risk money
A backtest is fit to the past, however lightly, so the last step is to run the survivor forward on markets whose outcome nobody knows yet. Deploy the rule to paper trading — or drive it from your own bot over a webhook — and it trades live books with virtual cash, filling at the real bid/ask and settling automatically at resolution. The equity curve it builds is the forward evidence a backtest can't give you.
That completes the loop: data → honest backtest → forward test. Kill ideas cheaply on history, graduate the ones that survive to live paper books, and only then consider real capital.
Common pitfalls
- Last-price or hourly data: hides the spread and misses the life of a 5–60 minute market.
- Mid fills: assuming zero slippage overstates edge, badly, on a contract that pays at most $1.
- Assumed settlement: label winners from the real reference price, not a guess — it's most of the P&L.
- Look-ahead bias: only react to data with a receive timestamp at or before your decision time.
- Skipping the forward test: an edge that only exists on settled history may not survive live markets.
Key takeaways
- 01Prediction markets settle to $0/$1 in minutes, so depth, timing, and settlement matter more than on any normal chart.
- 02Backtest against recorded full-depth books and inspect the stored cadence and gaps; activity between observations is not reconstructed.
- 03Model fills against depth (walk the book); a mid fill quietly overstates edge on a contract that pays at most $1.
- 04Settle at the real resolution and sanity-check the near-coin-flip split; mislabeled settlement flips winners.
- 05Run it no-code in the Backtest Lab or over the API, then forward-test the survivor on live books with paper trading.
DepthFeed serves the full Polymarket & Kalshi order book over a REST API and live WebSocket. Free Explorer tier, no card.
Start freeView pricing