A fill occurs when a trading order is executed, meaning a buyer and seller have been matched at an agreed price for a specified quantity. In live trading, fills happen through exchange matching engines. In backtesting, fill modeling is one of the most critical components because it determines whether simulated execution accurately reflects what would happen in real markets.
Types of fills
A complete fill means the entire order quantity was executed at the desired price or better. A partial fill means only a portion of the order was executed, with the remainder either left open or canceled. The distinction matters because partial fills affect strategy performance: a strategy that assumes it can always fill its full desired quantity may significantly overestimate returns.
Fills can also be categorized by their relationship to the intended price. A fill at or better than the limit price is favorable. A fill worse than expected, common with market orders during volatile periods, represents slippage.
Fill modeling in backtesting
The realism of fill modeling directly determines the reliability of backtest results. Naive backtesting engines assume that any order fills instantly at the signal price, ignoring the mechanics of real order execution. This creates several problems.
First, ignoring the bid-ask spread. A buy order fills at the ask, not the mid price. For frequently traded instruments, this difference might be small, but it compounds over hundreds of trades. For less liquid instruments, the spread can be a significant cost.
Second, ignoring volume constraints. In reality, an order can only fill against available liquidity. If a strategy wants to buy 10,000 shares but only 500 are available at the ask price, the remaining 9,500 shares must fill at higher prices. Backtests that ignore this volume constraint will overstate returns for larger position sizes.
Third, ignoring queue position. For limit orders, the time-priority queue determines fill order. A limit buy placed at the bid price will only fill after all other limit orders ahead of it in the queue have been filled. Realistic backtesting should model the probability of fill based on volume traded at or below the limit price.
Market impact
Market impact is the price movement caused by the act of trading itself. Submitting a large buy order increases demand and pushes the price up, meaning the average fill price is worse than the price observed before the order was submitted. Market impact models estimate this cost based on order size relative to average volume, market volatility, and the instrument's liquidity characteristics.
Practical example
A strategy generates a buy signal for 5,000 shares of a stock trading at $100.00 bid, $100.05 ask. The average volume at the ask is 2,000 shares per price level. With a naive fill model, the entire order fills at $100.05 (the ask). With a realistic fill model, the first 2,000 shares fill at $100.05, the next 2,000 at $100.10, and the final 1,000 at $100.15. The average fill price is $100.09 instead of $100.05, a difference of 4 basis points that compounds across all trades.
How Tektii helps
Tektii's backtesting engine uses a realistic fill model that accounts for bid-ask spread, available volume, partial fills, and market impact. Orders are executed against actual historical tick data, meaning the fill price reflects the liquidity that was genuinely available at the time. This prevents traders from being misled by backtest results that assume frictionless execution.