Quant Memo
Core

Backtesting A Market Making Strategy

Why testing a market-making strategy on historical data is unusually hard compared to backtesting a directional strategy, and what a realistic simulation has to model.

Prerequisites: Fill Ratios And Hit Rates, Adverse Selection

Backtesting a directional strategy is relatively straightforward: replay historical prices, apply the strategy's buy and sell rules, and see what would have happened. Backtesting a market-making strategy is much harder, because the strategy's own presence changes the outcome — a resting limit order in a historical replay either would or wouldn't have been filled depending on exactly what else was happening in the book at that instant, and a naive backtest has no way to know.

The core problem: counterfactual fills

A directional strategy that buys at the market has a fill that's almost guaranteed, at a price read straight off the historical tape. A market-making strategy posts a passive order and waits — whether it gets filled depends on whether real orders in history actually reached that exact price level while your order was resting there, and assuming every touched price level fully fills a resting order systematically overstates how much of the strategy's flow was real. A backtest also has to guess where in the queue your hypothetical order would have sat, since exchanges fill orders at a price level in arrival order (price-time priority), and an order that arrived a millisecond "later" in a replay might not have been filled at all even though the price level did trade.

Worked example: naive versus queue-aware fill assumptions

A backtest replays a day where the best bid touches $50.00 exactly once, and 500 shares trade at that level before the price moves away. A naive backtest assumes the strategy's simulated 1,000-share bid at $50.00 was fully filled, because the price level "traded." A queue-aware backtest instead reconstructs the order book, estimates how much size was already resting ahead of the simulated order at that price and time, and concludes that only 200 of the 500 shares that traded would have reached the simulated order — the rest went to orders that arrived earlier. The naive backtest overstates fills by 5x at that price level alone, which directly inflates the simulated strategy's estimated profit, since a market maker that thinks it got filled more than it would have also thinks it earned more spread than it would have.

orders ahead in queue your order 500 shares trade at this level
Only the portion of traded volume that clears everything ahead of your order in the queue actually reaches it — ignoring queue position overstates simulated fills.

What this means in practice

A realistic market-making backtest requires reconstructing the full limit order book at message-level granularity, modeling queue position explicitly, and often also modeling latency — the delay between deciding to post or cancel a quote and that action actually reaching the exchange, during which the market can move. Skipping any of these tends to bias results in the same direction: a naive backtest looks more profitable in simulation than the strategy could realistically achieve live, because it silently assumes perfect, instantaneous fills at favorable queue positions that real trading rarely provides.

Backtesting a market-making strategy requires simulating fills counterfactually — whether a resting order would actually have been reached given queue position and price-time priority — rather than assuming every price level that traded historically would have filled a hypothetical resting order there, an assumption that systematically overstates simulated profitability.

The most common mistake is backtesting market making with the same tools built for directional strategies, which assume fills happen at the observed trade price whenever the strategy "would have" traded. This ignores queue position entirely and routinely produces simulated results that look far better than live performance ever will.

Related concepts

Practice in interviews

Further reading

  • Cartea, Jaimungal & Penalva, Algorithmic and High-Frequency Trading, ch. 13
ShareTwitterLinkedIn