Skip to content
All library documents

Modeling Order Fills and Queue Position in Market-Data Replay Backtests

Article Stratmill research code

Summary

This HftBacktest documentation explains how exchange fill rules and queue-position assumptions shape market-data replay backtests. It contrasts a default model that fills orders completely with an alternative that allows partial fills when a trade reaches an order at the front of the queue. Both models specify price and trade conditions for resting buy and sell orders. For liquidity-taking orders, fills depend on displayed book liquidity, but the replayed market itself does not change.

The document then describes queue models for venues that provide market-by-price rather than market-by-order data. A conservative model advances an order only when trades occur at its price; probabilistic models distribute cancellations or quantity decreases before and after the order according to its queue position. Any probability function should assign zero probability to decreases ahead of an order at the queue head and certainty to decreases ahead at the tail. These are simulation assumptions, not evidence of live execution quality. Because the replay cannot reflect market impact or alter subsequent depth and trades, large simulated orders can receive unrealistic fills; live outcomes should be compared with backtests.

Key ideas

  • Replay-based backtests assume the simulated order does not change market prices, depth, or trades.
  • The no-partial-fill and partial-fill exchange models use different conditions for resting-order execution.
  • The documented liquidity-taking rules may overstate fills for large orders because replayed liquidity remains unchanged.
  • When market-by-order data is unavailable, queue position can be estimated with conservative or probabilistic models.
  • A probabilistic queue function should assign zero probability to cancellations ahead at the queue head and certainty at the tail.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.