How to Backtest Polymarket Strategies with Historical Orderbook Data
Updated
You can backtest a Polymarket strategy by replaying historical orderbook snapshots — full bid/ask depth, mid prices, and spreads at the tick level — and simulating fills against that depth rather than against a single price. Resolved Markets provides this data through a REST API, WebSocket streams, and a backtester that accepts a strategy described in plain English and returns the code, equity curve, and trades. The approach below works for prediction, crypto, sports, weather, and economic markets, and a free tier is available (the site advertises 10,000 credits on signup, with an additional 10,000 credits for signing up on Polymarket through their referral link, once per account).
Step 1: Get data access
Generate a free API key from the Resolved Markets dashboard — the site states no account creation or credit card is required for the key itself. You then have two access patterns:
| Access type | Use it for |
|---|---|
| REST APIs | Historical exports, time-based queries at specific timestamps |
| WebSocket streams | Live orderbook data for forward-testing or monitoring |
| Replay snapshots | Reconstructing event-driven probability movement minute by minute |
The dataset covers 4.2B+ orderbook snapshots across 184 recurring and event series since March 2026, with 100+ markets tracked across 7 categories. Each snapshot includes full bid/ask depth, mid prices, spreads, and crypto spot price — the spot price matters if your strategy trades crypto prediction markets and you want to condition entries on the underlying.
A minimal authenticated request looks like this:
fetch('/v1/markets/live', {
headers: { 'X-API-Key': key }
})
Step 2: Define the strategy in testable terms
A backtest is only as good as the rules you feed it. Before touching data, write down four things:
- Market selection — which series or categories, and how you filter (e.g., minimum liquidity, time to resolution, spread ceiling).
- Entry rule — the exact condition, expressed in fields the data actually has: mid price crossing a threshold, spread narrowing below X, spot price moving Y%, or a time-based query at a specific timestamp.
- Exit rule — resolution, a target price, a stop, or a time limit.
- Position sizing — how much you'd commit given the depth available at that moment.
If you use the plain-English backtester, this is where you describe the strategy; the agent converts it to code and runs it. If you're building your own pipeline, the same four items become your function signature.
Step 3: Run the backtest
The core loop is: fetch snapshots in time order → reconstruct the book at each timestamp → check your entry/exit conditions → simulate the fill against available depth → record the trade.
The fill simulation is the part most people get wrong. Don't assume you get filled at the mid price. Walk the book:
- If you're buying, consume asks from the best price upward until your size is filled.
- If you're selling, consume bids from the best price downward.
- Record the volume-weighted average fill price, not the top-of-book price.
- If your size exceeds the depth at your limit, either cap the fill or reject the trade — don't silently fill the whole order.
The expected output is a trade log (timestamp, side, size, fill price, fees if modeled) plus a mark-to-market equity curve built from the mid price between trades.
Step 4: Read the results honestly
Three outputs matter:
- Equity curve — look at drawdown shape, not just the final number. A curve that only works because of one spike is a red flag.
- Trade list — check whether your winners cluster in a few markets or a few time windows. Concentration means the edge may be an artifact.
- Fill realism — compare your assumed fill prices against the spread at entry. If your average fill is at or better than the mid, your simulation is probably too generous.
Common pitfalls
Thin liquidity. Prediction markets can have wide spreads and shallow books, especially far from resolution. A strategy that looks profitable at mid price can lose money once you walk the book. Always simulate against depth.
Short data history. The dataset starts March 2026. Strategies that depend on a full market cycle — election seasonality, a crypto bull/bear swing — may not have enough history to validate. Check how many distinct regimes your sample covers before trusting a result.
Overfitting to viral moments. The platform explicitly supports replaying reactions to viral events, Elon tweets, breaking news, and meme cycles. That's useful for studying behavior, but it's also a trap: if you tune parameters until the strategy nails three specific news spikes, you've fit noise. Test on held-out time periods and markets you didn't tune on.
Ignoring the spot price link. In crypto prediction markets, the outcome probability often tracks the underlying spot price. If your backtest ignores spot, you may attribute to "market sentiment" what is actually a mechanical relationship — and that relationship may not hold in a different regime.
A practical starting sequence
- Generate an API key.
- Pull one market series you understand well and export the snapshots.
- Write a single, simple rule (e.g., buy when mid < 0.30 and spread < 0.02, exit at resolution).
- Run it with realistic book-walking fills.
- Compare the equity curve against a buy-and-hold baseline on the same markets.
- Only then add complexity — and re-test on a different time window each time.
If the simple version doesn't beat the baseline after realistic fills, more parameters won't fix it.