TradeLabs AILearn

Fill Models, Partial Fills and Order Queues

A fill model decides when and at what price backtest orders execute. Learn market, limit and stop fill assumptions, queue position and adverse selection.

Advanced3 min readUpdated 3 Oct 2026
Markdown
Lesson 18 of 38

A backtest must decide what happens when the strategy sends an order: does it fill, at what price and how much? These rules make up the fill model. Optimistic fill models are a hidden source of fake profits, especially for strategies that use limit orders, trade small moves or depend on precise entries. Realistic fill modelling matters most for short term strategies, where a tick or two per trade can be the entire edge.

Fill assumptions by order type#

OrderSimple assumptionMore realistic assumption
Market orderFill at the next bar's open or last priceFill at the ask (buy) or bid (sell), plus slippage scaled to size and volatility. See Market Orders
Limit orderFill if price touches the limitFill only if price trades through the limit, or after your queue position is reached. See Limit Orders
Stop orderFill at the stop priceFill at the next available price after the stop triggers, often worse in gaps. See Stop Orders
Stop limitFill at the limitMay not fill at all if price gaps past the limit. See Stop-Limit Orders

The limit order problem#

Limit orders look great in naive backtests: you buy at your price whenever it is touched. In reality:

  • Queue position: other orders at the same price fill first. Price may touch your level without reaching your order. See Fill Probability and Queue Position.
  • Adverse selection: your limit buys tend to fill when the price keeps falling, and miss when it bounces immediately. Filled orders are disproportionately the bad ones.

Partial fills and size#

Large orders relative to available liquidity may fill only partly or move the price. A fill model can cap fills at a share of the volume traded in each bar, such as 5% to 10%, and apply market impact to larger orders. See Market Impact.

Gaps and stops#

Stops do not protect against gaps. If a stock closes at $50 and opens at $44 after bad news, a stop at $48 fills near $44. Backtests should fill stops at the first available price after the trigger, including gaps. See Price Gaps and How to Trade Them.

Data resolution matters#

DataFill modelling quality
Daily barsOnly rough; intraday order of highs and lows unknown
Minute barsBetter; still ambiguous within each bar
Tick or trade dataGood for trade through tests
Order book data (Level 2 or 3)Allows queue position modelling. See Order Book Feeds: Snapshots and Incremental Updates

Ambiguous bars should be resolved conservatively, such as assuming the stop was hit before the target.

A conservative default fill model#

  1. Market orders: fill at the next available price, crossing the spread, plus slippage.
  2. Limit orders: fill only when price trades through by at least one tick, and cap size by volume.
  3. Stops: fill at the next price after triggering, including gaps.
  4. Ambiguous bars: assume the worse outcome.
  5. Compare with live fills once trading and adjust. See Slippage Analysis.

Simulating with market replay#

For high frequency strategies, firms replay historical order book data through a simulated exchange matching engine, modelling queue position and latency. This is the most realistic approach but requires detailed data and engineering. See Market Data Replay and Matching Engines.

Frequently asked questions#

What is a fill model in backtesting?#

The set of rules a backtest uses to decide whether orders execute, at what price and in what quantity.

Why do limit orders look too good in backtests?#

Because naive models fill them whenever price touches the limit, ignoring queue position and the tendency for limit orders to fill mainly before adverse moves.

How should stop orders be filled in a backtest?#

At the first available price after the stop is triggered, which can be much worse than the stop price when markets gap.

Next, learn to test many positions together in Portfolio and Multi-Asset Backtesting.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonPortfolio and Multi-Asset BacktestingPortfolio backtests simulate many positions with capital limits, sizing and rebalancing. Learn the key design choices, constraints, metrics and pitfalls.

Mentioned in