How to Backtest a Polymarket Strategy with Historical Orderbook Data
Updated
To backtest a Polymarket strategy, you need tick-level historical orderbook snapshots — not just price charts — so you can simulate fills against real bid/ask depth at specific timestamps. Resolved Markets provides this: 4.2B+ orderbook snapshots across 184 recurring and event series since March 2026, accessible via REST, WebSocket, MCP, and a built-in backtester, with a free tier and a free API key (no credit card). This guide covers the full workflow: sourcing data, replaying market conditions, defining rules, simulating fills, and evaluating results.
What Historical Polymarket Data You Actually Need
Prediction market backtests fail when they use mid prices alone. A YES contract trading at $0.60 mid might have $50 of depth at $0.59 and $0.61 — your $500 order would move the market. You need:
| Data type | Why it matters | What to look for |
|---|---|---|
| Tick-level orderbook snapshots | Simulates realistic fills | Full bid/ask depth, not just top-of-book |
| Mid prices | Baseline probability tracking | Per snapshot |
| Spreads | Transaction cost modeling | Bid-ask spread at each tick |
| Crypto spot price | Context for crypto prediction markets | Included per snapshot in Resolved Markets |
| Timestamps | Event replay and look-ahead prevention | Sub-minute granularity |
Resolved Markets captures every snapshot with full bid/ask depth, mid prices, spreads, and crypto spot price. Coverage spans crypto prediction markets, politics and elections, sports and live events, economic indicators, and weather — 100+ markets tracked across 7 categories and 30+ cities.
Step 1: Get Data Access
- Generate a free API key — Resolved Markets issues one instantly with no account creation and no credit card required.
- Explore the API — 11 endpoints with live examples you can test directly from the documentation.
- Pull historical data — Use REST APIs for historical exports and structured schemas, or WebSocket streams for live data. Replay snapshots let you reconstruct specific timestamps.
Example request pattern from the docs:
fetch('/v1/markets/live', {
headers: { 'X-API-Key': key }
})
For backtesting you'll want the historical export endpoints rather than the live feed. If you sign up on Polymarket through the Resolved Markets referral link, you get 10,000 free API credits added to your account (once per account).
Step 2: Reconstruct Market Conditions at Specific Timestamps
This is where orderbook data separates real backtests from curve-fitting. Time-based queries let you navigate market conditions across specific timestamps and reconstruct event-driven probability movement.
The practical approach:
- Pick your event window. If you're testing a strategy around breaking news or viral moments, pull snapshots minute-by-minute through the reaction period. Resolved Markets explicitly supports replaying market reactions to viral moments, tweets, breaking news, meme cycles, and crowd sentiment shifts.
- Load the full book at each tick. Not just the mid — the entire bid/ask ladder.
- Track liquidity changes. How did depth thin out as the event approached resolution? Did spreads widen?
A concrete example: you want to test whether buying YES on a crypto market 30 minutes before a scheduled announcement is profitable. You need every snapshot in that 30-minute window, plus the resolution outcome, to know whether the position would have settled in your favor.
Step 3: Define Entry/Exit Rules and Simulate Fills Against Depth
Write your rules as explicit conditions on orderbook state, not just price:
- Entry: "Buy YES when mid price crosses $0.55 AND top-of-book ask depth exceeds 200 shares AND spread < $0.02."
- Exit: "Sell when mid reaches $0.70 OR 2 hours before resolution, whichever comes first."
- Position sizing: Cap order size at a fraction of visible depth (e.g., 10% of ask-side liquidity) to avoid unrealistic fills.
Simulating fills correctly: Walk the ask ladder. If you're buying 500 shares and the book shows 200 at $0.56, 200 at $0.57, and 300 at $0.58, your average fill is not $0.56 — it's a weighted average across those levels. Backtests that assume top-of-book fills systematically overstate returns.
Resolved Markets' backtester accepts a strategy described in plain English, then returns the code, equity curve, and trades — useful for quickly testing an idea before building a full simulation.
Step 4: Evaluate Results with Prediction-Market-Specific Metrics
Standard equity curves and trade logs are necessary but not sufficient. Prediction markets have dynamics that equity backtests miss:
- Resolution risk: A position can go to $0 or $1 at settlement. Your equity curve must model binary outcomes, not continuous price paths.
- Time decay near resolution: Prices converge to 0 or 1 as the event resolves. Strategies that hold to resolution face different risk than those that exit early.
- Liquidity evaporation: Depth often thins dramatically in the final hours. A strategy that looks profitable on mid-price signals may be unfillable at scale.
- Spread costs: On a $0.60 contract, a $0.02 spread is 3.3% of notional per round trip. Model this explicitly.
Track: total return, Sharpe ratio (annualized appropriately for event-driven timing), maximum drawdown, win rate, average fill slippage vs. mid, and number of trades where your order size exceeded available depth.
Step 5: Validate and Watch for Common Pitfalls
Out-of-sample testing: Split your data by time period, not randomly. Train on events from one quarter, test on the next. Prediction market regimes shift with news cycles.
Look-ahead bias: The most common failure. If your strategy uses "the resolution outcome" as an input before the market resolved, you've leaked future information. Every signal must use only data available at that timestamp.
Survivorship bias: If you only test markets that resolved (and exclude ones that were cancelled or delisted), your results are skewed. Resolved Markets' coverage of 184 recurring and event series helps here — you can test across the full universe, not just winners.
Overfitting to specific events: A strategy tuned to one viral moment won't generalize. Test across multiple event types (crypto, sports, politics) and time periods.
Validate against live data: Run your strategy in paper-trading mode against the live feed before committing capital. Compare simulated fills to what the live orderbook would have given you.
Quick Reference: The Full Workflow
- Get a free API key from Resolved Markets (instant, no credit card).
- Pull tick-level orderbook snapshots for your target markets and time windows via REST historical exports.
- Reconstruct the full bid/ask ladder at each timestamp.
- Define entry/exit rules as conditions on orderbook state.
- Simulate fills by walking the depth ladder, not assuming mid-price fills.
- Evaluate with equity curves, trade logs, and prediction-market-specific metrics (resolution risk, spread costs, liquidity evaporation).
- Validate out-of-sample and check for look-ahead and survivorship bias.
- Paper-trade against live data before going live.
The free tier and 10,000 referral credits make steps 1–3 accessible without upfront cost. The backtester's plain-English strategy input lets you iterate quickly on steps 4–6 before writing production code.