Guide

Walking the order book ladder in Polymarket backtests

Polymarket's Up/Down markets form a ladder: many contracts at adjacent strikes, each with its own book. When an order is larger than the size at one level, it walks up the ladder. Modeling that walk is the difference between a plausible and a fantasy fill.

What this guide covers

  • The archive stores bids and asks per token, so each rung of a ladder is a separate book
  • Between consecutive levels the marginal price steps, so the average fill lags the best level
  • Level spacing is not uniform across assets, so a fixed level count misprices thin ladders
  • The snapshot endpoint reports per-token bids and asks with a null mid when one side is empty

What ladder-walking means

A single market has one book with many price levels. A strike ladder is many markets whose books sit next to each other. Walking the ladder means your order consumes the best rung, then the next rung, and so on, with the average fill price rising as it consumes cheaper liquidity.

This is the correct model whenever an order is large relative to any single rung. Because the archive stores each token's book separately, you can replay the walk level by level and see exactly where the average lands.

Level spacing drives the cost

Two ladders with the same total depth can give very different fills depending on how far apart the rungs are. A tightly packed ladder keeps the walking cost small; a sparse one makes each step expensive. Because spacing differs by asset and by window, a fixed 'walk three levels' rule misprices most markets.

Compute the walk from the actual stored levels rather than a fixed count. The data tells you the spacing; assuming it throws away the very information the backtest needs.

One-sided and empty rungs

Ladders are uneven. Some rungs have deep two-sided books, others are one-sided, and some have no asks at all. A walk that assumes a continuous ladder will happily fill through a rung that was empty at that instant, producing trades that never could have happened.

The archive reports a null mid when a side is empty precisely so you can detect this. Treat a missing side as a wall: the walk stops there, and the order either rests or is rejected.

Order slicing across the ladder

If you spread one large order across several rungs, each rung gets only part of the size and consumes less depth, which lowers the average cost. That is the practical case for slicing, and the backtest can measure it: simulate a child order per rung and sum the fills.

Do not confuse slicing across rungs with time-slicing a single order. The first reduces depth slippage by using more of the ladder's breadth; the second trades one rung at a time and risks being adversely selected. Model whichever you would actually do.

Code examples

# Walk several ladder rungs and average the fills.
def fill_ladder(rungs, size):
    # rungs: list of (levels) ordered best to worst
    remaining = size
    notional = 0.0
    for levels in rungs:
        for price, qty in levels:
            take = min(remaining, qty)
            notional += take * price
            remaining -= take
            if remaining <= 0:
                return notional / size
    return None  # ran out of ladder before filling

Free tier

The Starter plan is free, includes order books, prices, and metrics at 250ms resolution, with 3 days of history, 60 requests/min, 1,000/day, 1 free AI backtest, and 3 strategy backtests. No credit card required.

Paid data windows from $19/mo extend history to 30–120 days at higher throughput. Backtest AI add-on is +$19/mo or standalone at $29/mo.

FAQ

What is ladder-walking?

Filling an order across multiple price levels, consuming resting size at each, so the average fill price steps away from the best level as size grows.

Why does level spacing matter?

The gap between consecutive levels sets how much the average fill drifts. Uneven spacing across assets means a fixed level-count model misprices most ladders.

How do I handle an empty rung?

Treat it as a wall. The archive reports a null mid for one-sided books, so a walk should stop rather than fill through a level that had no resting size.

Is slicing across rungs the same as time-slicing?

No. Slicing across rungs uses the ladder's breadth to cut depth slippage; time-slicing trades sequentially and risks adverse selection. Model the one you would actually run.