How to Backtest Your Polymarket Strategy with Historical Orderbook Data
Updated
To backtest a Polymarket strategy, you need historical orderbook snapshots — not just final prices — so you can replay the bid/ask depth your strategy would have traded against. Resolved Markets provides tick-level snapshots (full bid/ask depth, mid prices, spreads, and crypto spot price) across prediction, crypto, sports, and weather markets, with REST APIs, historical exports, WebSocket streams, and a backtester that takes a plain-English strategy description and returns code, an equity curve, and trades. A free tier and a free API key (no account creation or credit card required) are available; check the pricing page for current limits.
What you actually need before starting
A backtest is only as good as its inputs. For prediction markets, three data properties matter more than raw price history:
| Requirement | Why it matters | |---|---|---| | Tick-level orderbook snapshots | A strategy that posts or takes liquidity depends on depth and spread, not just the last trade price | | Timestamped snapshots | You must reconstruct the market exactly as it looked when your signal fired | | Category coverage | Crypto, politics, sports, and weather markets behave differently; test on the categories you trade |
Resolved Markets reports 4.2B+ orderbook snapshots across 184 recurring and event series since March 2026, covering 100+ markets and 7 categories. If your strategy depends on a market outside that coverage, the backtest can't validate it.
Step 1: Get data access
- Generate a free API key — the site states this requires no account creation and no credit card.
- Browse the API reference (11 endpoints with live examples) and test requests directly from the documentation.
- Confirm your target markets exist in the historical dataset before writing strategy code.
A minimal live-data call looks like this, which you can adapt to historical endpoints:
fetch('/v1/markets/live', {
headers: { 'X-API-Key': key }
})
Expected result: you receive structured market data you can query by timestamp. If a market returns no history, stop here — no amount of strategy logic will fix missing data.
Step 2: Reconstruct market conditions at specific timestamps
This is the core of prediction-market backtesting and where most naive backtests fail. Use time-based queries to pull the snapshot state at each moment your strategy would have acted.
For each decision point, extract:
- Best bid and best ask
- Full depth on both sides
- Mid price and spread
- Crypto spot price, if your market is crypto-linked
Then ask: could my order actually have filled at this price, given this depth? A signal that looks profitable on mid prices can vanish once you account for spread and available size.
Step 3: Define strategy logic against real fields
Map your idea to the fields the data actually exposes. For example, a strategy like "buy when the spread narrows and mid price crosses 0.60 with at least X size on the bid" is testable; "buy when sentiment turns bullish" is not, unless you define sentiment as a measurable series.
If you use the built-in backtester, you can describe the strategy in plain English and it returns the code, equity curve, and trades — useful for quickly checking whether an idea is even coherent before building it out.
Step 4: Run the backtest and inspect outputs
Look at three things, in this order:
- Trades — Did each fill happen at a price and size the orderbook could support? Reject any trade that assumed liquidity that wasn't there.
- Equity curve — Check drawdown shape, not just final return. A curve that depends on one lucky event is not a strategy.
- Code — If using the agent-generated backtest, read the code to confirm it implements what you intended, not a plausible-looking approximation.
Step 5: Validate against real market behavior
Prediction markets react to discrete events — viral moments, breaking news, tweets, meme cycles. Resolved Markets explicitly supports replaying these reactions minute by minute. Use this to stress-test:
- Does your strategy survive the volatility spike around a news event?
- Does it degrade when spreads widen during low-liquidity periods?
- Does performance differ across categories (crypto vs. sports vs. politics)?
Common pitfalls
- Backtesting on mid price only. Ignores spread and depth; overstates fills.
- Ignoring the event-driven nature of prediction markets. Probability jumps are often discontinuous, so stop-loss and limit logic behave differently than in continuous markets.
- Testing outside your data coverage. If the market or time period isn't in the dataset, results are fabricated.
- Treating a generated backtest as ground truth. Always read the code and verify the fill assumptions.
- Assuming free means unlimited. A free tier and free API key exist, but credit limits and pricing terms are on the pricing page — verify before scaling.
When this approach fits
Use historical orderbook backtesting when your strategy depends on execution quality — posting liquidity, capturing spread, or sizing into depth. If your strategy only acts on final outcomes and never touches the book, simpler price history may suffice, and the full snapshot pipeline is more than you need.