Learn how to model slippage, spreads, commissions, and uncertain fills in a backtest, then stress-test whether the strategy can withstand higher execution costs.
Quick Answer
Model slippage in backtesting as one part of a complete execution model. Separate commissions, bid-ask spread, adverse price movement, fill uncertainty, and market impact. Apply each cost according to the strategy’s instrument, order type, session, and position size, then rerun the test under increasingly adverse assumptions. The main limitation is data quality: candle data cannot reliably reconstruct intrabar sequencing, historical quotes, queue position, or the exact price at which an order would have filled.
Key Takeaways
- Model commissions, spread, slippage, and market impact separately so you can audit each assumption.
- Match execution rules to the instrument, order type, trading session, liquidity, and holding period.
- Do not assume a limit order filled merely because the historical price touched its limit.
- Avoid charging for the spread twice if the backtest already executes buys at the ask and sells at the bid.
- Test a range of plausible costs rather than relying on one precise estimate.
- Treat a strategy that depends on ideal fills as fragile, even when its gross results look strong.
What Slippage in Backtesting Means
Slippage is the difference between the reference price used when a trading decision is made and the price at which the order is modeled as filled.
Suppose a strategy generates a buy signal at $50.00. By the time its market order is eligible to execute, the available price is $50.03. The entry experienced three cents per share of adverse slippage.
Slippage is not the same as total trading cost. A complete model may include:
- Commissions and fees: Explicit charges associated with orders or executions.
- Bid-ask spread: The difference between the best available buying and selling prices.
- Slippage: Fill deterioration relative to the strategy’s reference price.
- Market impact: Additional price movement caused by the order itself.
- Holding costs: Borrow fees, margin interest, funding payments, or other costs incurred while carrying a position.
Keep these components separate unless you know exactly what a combined deduction represents. If a backtest already buys at historical ask prices and sells at bid prices, it has incorporated the displayed spread. Deducting another full spread would count the same cost twice.
Why Unrealistic Fills Distort More Than Net Returns
Execution assumptions can affect whether an entry occurs, which exit happens first, how many units are purchased, and whether a trade complies with the strategy’s risk limit. Subtracting a fixed cost after the backtest cannot capture all of these interactions.
The issue is especially important for strategies with:
- High turnover
- Small average gains per trade
- Short holding periods
- Tight stops or targets
- Market orders during fast conditions
- Entries near a session open
- Thinly traded instruments
- Orders large relative to available liquidity
Express costs in the same unit used to evaluate the strategy. If results are measured in R, calculate execution cost in R. If the research uses basis points, convert costs into basis points. That makes cost sensitivity comparable across instruments and position sizes.
How to Model Slippage in Backtesting
1. Define the path from signal to order
Document when the signal becomes knowable and when an order can first be submitted. Specify the order type, sizing rule, partial-fill treatment, and what happens when the requested price is unavailable.
A signal calculated from a completed candle generally should not receive a fill earlier in that candle. Depending on the strategy and available data, the first defensible fill may occur at the next bar or next eligible market event.
2. Identify what the historical data supports
OHLC candles reveal a bar’s open, high, low, and close, but not necessarily the sequence of prices within it. If a stop and target are both inside the same candle, the data may not show which was reached first.
Higher-resolution trade or quote data can improve sequencing. It still may not reveal your order’s queue position or guarantee that sufficient liquidity was available. The fill model should never imply more precision than the data supports.
3. Add commissions and explicit fees
Apply the relevant fee structure to every execution, including partial entries and exits. Costs may be assessed per order, share, contract, or amount traded.
A strategy that enters once and exits in three pieces can incur a different total cost from one using a single round trip. If historical fee schedules are unavailable, document the chosen assumption and include higher values in the sensitivity test.
4. Model the bid-ask spread
For marketable orders, a basic quote-aware model buys near the ask and sells near the bid. If the dataset contains only midpoint or last-trade prices, the spread may need to be approximated.
A fixed spread can be useful for an initial screen, but spreads change with volatility, liquidity, session, and price level. Intraday strategies should consider different assumptions for the open, normal trading hours, and less liquid periods.
5. Choose a slippage model
Common approaches include:
- Fixed: Add a set number of ticks or cents to each execution.
- Percentage-based: Scale slippage with the instrument’s price.
- Volatility-based: Increase the deduction as recent volatility rises.
- Liquidity-based: Increase expected cost as order size grows relative to volume or available liquidity.
- Delay-based: Execute at a later eligible event to represent calculation, transmission, and processing time.
A simple model with documented assumptions is usually more useful than a complex model built from unsupported parameters. Complexity does not create accuracy by itself.
6. Use conservative limit-order rules
A limit price being touched does not prove that an order filled. Other orders may have been ahead in the queue, traded volume may have been insufficient, or the market may have touched the price briefly.
Possible rules include requiring price to trade through the limit, requiring minimum volume at or beyond the price, delaying fill eligibility, or testing multiple fill probabilities. Also define what happens when the order remains unfilled. Missed trades are part of the execution model.
7. Build a cost sensitivity matrix
Run several coherent scenarios:
- Low cost: Favorable but plausible conditions
- Base cost: The documented working assumption
- Adverse cost: Wider spreads, delayed fills, or greater slippage
- Severe stress: Unusually poor liquidity or volatile execution
Compare net expectancy, maximum drawdown, trade count, profit factor, and losing streaks. The objective is not to predict one exact future cost. It is to locate the point at which execution deterioration changes the research conclusion.
8. Compare the model with forward observations
Paper trading and controlled small-size observations can expose differences between assumed and observed order behavior. Record the signal price, submission time, order type, prevailing spread, fill price, and position size.
Do not recalibrate the entire model from a handful of fills. Look for persistent discrepancies, revise the assumption transparently, and validate the change on separate data.
A strategy laid out end to end in the Kvants editor.
Worked Example: From Gross to Net Results
Assume a stock strategy produced 100 historical round trips using 100 shares per trade. Its gross result before costs was $2,500.
The researcher models the following round-trip costs:
- Commissions and explicit fees: $1.20
- Spread: one cent per share at entry and exit, totaling $2.00
- Additional slippage: half a cent per share at entry and exit, totaling $1.00
Estimated cost per trade is $4.20. Across 100 trades, modeled costs total $420:
$2,500 gross result − $420 costs = $2,080 net result
Average performance falls from $25.00 to $20.80 per trade. If planned risk was $100 per trade, execution costs equal 0.042R per trade, and average performance falls from 0.25R to 0.208R.
That calculation is only a first pass. A stronger test also delays selected entries and widens the spread during less liquid periods. A later fill can alter the stop distance, position size, trade eligibility, and order of exits. Those effects require execution-aware simulation rather than a deduction applied after every trade is complete.
A backtest's equity curve and trade-by-trade log.
Common Execution-Model Failure Modes
Assuming zero costs
A zero-cost result is an upper bound, not a realistic baseline. The distortion grows as turnover increases and average trade size decreases.
Applying one average to every condition
An overall average can hide deterioration during volatile or illiquid periods. Where the sample permits, segment observed costs by instrument, session, order type, and volatility regime.
Double-counting the spread
Check whether the data and execution engine already distinguish bid and ask prices. If they do, an additional spread deduction may duplicate an included cost.
Guaranteeing limit-order fills
A touched price is not proof of execution. Generous limit-fill rules can materially inflate trade count and strategy results.
Ignoring intrabar sequencing
Candle-based tests may award a target before a stop without evidence that the target occurred first. Use higher-resolution data, event-driven logic, or an explicitly conservative assumption when the sequence matters.
Adjusting costs to rescue the result
Set cost assumptions before inspecting their effects. Reducing modeled slippage because the strategy fails after costs reverses the proper research process.
Auditing Execution Assumptions With Kvants
Kvants Studio turns plain-English trading ideas into editable, auditable strategy logic. Backtests run on NautilusTrader’s event-driven engine, which is relevant when order sequencing and strategy state affect the result.
Parameter sweeps can compare a range of cost assumptions instead of relying on one preferred value. Walk-forward analysis and crisis-stress validation can then test whether the conclusion persists outside the conditions used to develop the strategy.
Document the signal timestamp, order type, fill rule, spread treatment, fees, and slippage range with the strategy. The Kvants documentation explains the research workflow, while the Kvants blog covers related validation and risk concepts.
Kvants audits that the engine runs the strategy you configured.
Frequently Asked Questions
How much slippage should I use in a backtest?
There is no universal value. The assumption should reflect the instrument, liquidity, volatility, session, order type, data resolution, and intended position size. Start with a documented baseline and test materially higher values.
Should slippage apply to entries and exits?
Usually, yes, when both sides can execute away from their reference prices. Stops may require harsher assumptions in fast markets. Limit exits need a fill rule rather than an automatic adverse-price deduction.
Are commissions and slippage the same?
No. Commissions are explicit charges. Slippage is the difference between a reference price and the modeled fill. Spread and market impact are related execution costs but should also be identified separately.
Can candle data model slippage accurately?
Candle data can support simplified assumptions, but it cannot reconstruct historical queue position, every spread change, or the sequence of all intrabar events. Use conservative rules or more granular data when those details determine the outcome.
How should limit orders be modeled?
Model both price eligibility and fill uncertainty. Define whether the market must touch or trade through the limit, whether volume is required, when the order becomes active, and what happens if it remains unfilled.
When does market impact matter?
Market impact becomes more relevant as order size grows relative to available liquidity or trading volume. Small orders in liquid markets may experience less impact, but the assumption should still be documented and tested.
Risk Note
This article is educational and is not investment advice. Execution models are estimates, and historical data cannot reproduce every real-world fill condition. Backtested performance does not guarantee future results. Kvants is a research tool, not an investment adviser, and does not guarantee performance.