All postsData & Analytics

Backtesting Prediction Market Arbitrage with Historical Data

PMA Research · · 7 min read · Updated

Backtesting Prediction Market Arbitrage with Historical Data — article illustration

Prediction market arbitrage looks like free money on a chart, but historical price data quietly lies to you. Building a backtest that survives contact with live order books requires reconstructing exact market depth, modeling dynamic fees, and ruthlessly eliminating look-ahead bias. If your simulation fills at the mid-price, you are not modeling a strategy; you are modeling a fantasy.

Key takeaways

  • Historical price charts cannot prove an order of your size would have filled; you must use order book snapshots to measure available liquidity.
  • Filling simulated orders at the last traded price or mid-price awards your strategy the spread, artificially inflating backtest returns.
  • Venues frequently resolve the "same" real-world event differently, meaning cross-exchange arbitrage carries hidden fundamental risk.
  • Accurate backtesting requires modeling capital lockup periods and dynamic taker fees, which severely impact high-frequency strategies.

Where can I find historical prediction market data?

Sourcing clean data is the first hurdle in quantitative modeling. Unlike traditional equities, prediction markets do not offer standardized, consolidated tape feeds. You must piece together history from venue-specific APIs and third-party archives.

Kalshi separates its API into live and historical tiers. To access older records, you must query the historical endpoints. The boundary between live and historical data advances over time, so you must check the current cutoff timestamps using the official endpoints. For example, you can retrieve settled markets older than the cutoff or fetch specific market details using the Kalshi historical endpoints. Kalshi also provides historical candlesticks at 1-minute, 60-minute, and 1440-minute intervals. When using the REST API (e.g., https://external-api.kalshi.com/trade-api/v2), note that the yes_dollars and no_dollars arrays contain dollar prices and fixed-point sizes, sorted ascending with the best bid last. Crucially, only bids are returned; to find the YES ask, you must calculate 1 - best NO bid Kalshi: Quick Start Market Data.

Polymarket data requires a different approach. While the venue offers a price-history endpoint, reconstructing the full order book depth historically is notoriously difficult. Because Polymarket settles on-chain, researchers often rely on public datasets hosted on Hugging Face or GitHub, which can reconstruct executed trades from blockchain logs, but not the complete off-chain resting order book or canceled quotes. Relying solely on trade prints will show you executed transactions but cannot reveal the resting liquidity you need to simulate large fills.

Why is matching markets across venues so difficult?

Cross-venue arbitrage assumes you are trading identical assets. In prediction markets, a standard winning token pays $1.00 at resolution and the losing token pays $0.00, but the conditions triggering that payout vary wildly between exchanges.

Venues can resolve the "same" event differently. One exchange might rely on an Associated Press race call to settle an election market, while another waits for congressional certification. Polymarket uses the UMA optimistic oracle for prediction markets (where disputes can take days) and Chainlink TWAP for up-down markets Polymarket: Resolution. If you buy YES on Venue A and NO on Venue B, a disputed outcome could result in both contracts resolving to NO, leaving you with a total loss.

When building your historical dataset, you must manually map contract rules, not just market titles. A robust backtest tracks the "leg failure rate," which measures how often one side of an arbitrage pair fails to execute or resolves unexpectedly. If your backtest assumes perfect fungibility between Kalshi and Polymarket contracts without checking the fine print, your results will be dangerously optimistic.

How do I model order book depth and slippage?

The most common mistake in backtesting is using the last traded price to simulate entries and exits. If a market is sitting at 61 cents bid and 65 cents ask, the last trade might have occurred at 63 cents. If your backtest assumes you can buy at 63 cents, you are quietly awarding your strategy the spread on every position.

To backtest honestly, you must cross the spread. A buy order crosses to the ask; a sell order crosses to the bid. Furthermore, candlestick data lacks order book depth. A 1-minute candle might show a favorable ask price, but it cannot tell you if there were 10 contracts or 10,000 contracts available at that level.

Slippage and Latency Checklist

  • Never fill at the mid-price: Always use the bid for selling and the ask for buying. Selling YES uses actual bids and collateral/venue permission.
  • Assume conservative slippage: If depth data is missing, penalize your fill price by several cents based on historical volume.
  • Model latency: Introduce a delay between your signal generation and the simulated fill to account for network routing.
  • Calculate fill probability: If the available size at the touch is smaller than your order, assume a partial fill or a worse average price.

What is the correct way to calculate fees and capital costs?

Arbitrage margins are razor-thin, making fee modeling critical. You cannot use a flat percentage fee across all venues and timeframes.

For example, the Kalshi general taker fee is calculated as round up(M * 0.07 * C * P * (1 - P)), where M is the multiplier (default 1 for takers), C is the number of contracts, and P is the price. The fee plus position cost is rounded up to a centicent Kalshi: Fee Schedule. You must read current precision from live fee parameters rather than assuming a hard cap.

Polymarket charges taker fees based on the formula fee = C * feeRate * p * (1 - p), rounded to five decimal places USDC, not cents Polymarket: Fees. The fee rate varies by category: Crypto is 0.07, Sports/Economics/Culture/Weather/Other is 0.05, Finance/Politics/Mentions/Tech is 0.04, and Geopolitics is 0. Makers are never charged fees.

| Metric | Description | Impact on Arbitrage | | :--- | :--- | :--- | | Net edge per contract | Expected profit after all fees and slippage | Determines if a trade is mathematically viable | | Capital-days | Amount of capital locked multiplied by days until resolution | Highlights the opportunity cost of tied-up funds | | Leg failure rate | Percentage of trades where only one side fills | Measures execution risk in cross-venue strategies |

Capital-days is a vital metric. A strategy might show a 2 percent return, but if the capital is locked for six months awaiting resolution, the annualized yield is terrible. Always run your strategy through a fee calculator to ensure the net edge justifies the capital lockup.

How do I prevent survivorship and look-ahead bias?

Survivorship bias occurs when your historical dataset only includes markets that resolved cleanly. If you drop voided, delisted, or disputed markets from your universe, you are ignoring the exact scenarios that cause catastrophic losses in live trading. Your backtest must include the ugly cases.

Look-ahead bias is equally destructive. This happens when your strategy accidentally uses information that was not available at the time of the trade. For instance, filtering your historical universe to only include markets that eventually reached $1,000,000 in volume means you are using future knowledge to select your trades today.

To audit your system, ensure every signal in your backtest is computed strictly from data available at that exact millisecond. This information is provided for educational purposes and is not financial advice.

Frequently asked questions

Can I use 1-minute candlesticks for high-frequency arbitrage?

No. Cross-venue arbitrage opportunities often open and close within seconds. A 1-minute candle aggregates this activity, hiding the micro-structure of the order book and making it impossible to verify if an order would have filled.

Why do my backtest profits disappear in live trading?

The most likely culprits are filling at the mid-price, ignoring taker fees, and failing to account for order book depth. Live trading forces you to cross the spread and compete with other participants for limited liquidity.

How do I get historical data for markets that are no longer active?

You must use dedicated historical API endpoints. For example, Kalshi archives settled markets, which can be accessed by checking the historical cutoff timestamps and querying the appropriate historical routes.

Sources

Information only, not financial advice. Trading prediction markets involves risk of loss.