TradeLabs AILearn

Costs and Slippage in Backtests

Ignoring costs is the fastest way to fool yourself in a backtest. Learn the costs to include, how to estimate slippage and market impact, and conservative rules.

Intermediate3 min readUpdated 3 Oct 2026
Markdown
Lesson 16 of 38

Many strategies that look profitable on paper are wiped out by trading costs. Commissions, spreads, slippage, market impact, financing and borrowing fees all reduce returns, and they matter most for strategies that trade often or target small moves. Modelling costs realistically, and conservatively, is one of the most important parts of a backtest. The general cost concepts are covered in All-In Trading Cost; this lesson focuses on putting them into backtests.

Costs to include#

CostApplies toLesson
Commissions and feesEvery tradeCommissions and Fees
Bid ask spreadMarket orders and aggressive limit ordersSpread Costs
SlippageDifference between expected and actual fill priceSlippage
Market impactLarger orders moving the priceMarket Impact
Financing and swap costsLeveraged and overnight positionsFinancing and Overnight Costs
Borrow feesShort selling stocksBorrow Fees and Stock Loan Costs
Futures roll costsRolling contractsRoll Costs
Funding ratesCrypto perpetual futuresFunding Rates
TaxesDepends on jurisdictionTrading Taxes and Capital Gains

How costs scale with trading frequency#

Estimating slippage#

ApproachDescription
Fixed per tradeA set number of ticks or basis points; simple
Spread basedHalf the typical spread per side, plus a buffer
Volatility basedSlippage proportional to recent volatility
Volume based (market impact models)Larger relative to average volume means larger cost
Live dataMeasure actual fills versus signal prices. See Slippage Analysis

A common square root market impact model:

impact ≈ k × σ × √(order size / average daily volume)

where σ is daily volatility and k a constant often estimated around 0.5 to 1. See Market Impact.

Conservative rules of thumb#

  1. Assume you cross the spread for market orders and many stops.
  2. Add extra slippage around open, close and news, when spreads widen.
  3. Do not assume limit orders always fill: filled limit orders are often the ones the market moved through against you. See Fill Models, Partial Fills and Order Queues.
  4. Scale costs with volatility and size.
  5. Run sensitivity tests at 1.5 times and 2 times your cost estimate. See Robustness and Stress Testing.
  6. Include financing for every night positions are held.
  7. Use realistic borrow costs and availability for shorts; some stocks cannot be borrowed.

Costs differ by market#

MarketTypical cost features
Large cap stocksTight spreads; impact matters for large orders
Small cap stocksWide spreads; high impact
FuturesCommissions per contract plus one tick spread in liquid contracts
ForexSpread based; widens in thin hours
OptionsWide spreads relative to price; often the dominant cost
CryptoMaker and taker fees; funding; spreads vary by venue
Prediction marketsSpread and fees; thin books in small markets

Validate with live trading#

After launching, compare actual costs with backtest assumptions. Implementation shortfall, the difference between the price when the decision was made and the final execution price, is the standard measure. See Implementation Shortfall.

Frequently asked questions#

Why are trading costs important in backtests?#

Because commissions, spreads, slippage and financing reduce returns, and they can eliminate the edge of strategies that trade often or target small moves.

How should I estimate slippage?#

Start with half the spread per side plus a buffer, scale with volatility and order size, and refine using actual live fills.

What is a conservative cost assumption?#

Assume you cross the spread, add slippage in volatile periods, include all financing and borrow costs and test at higher cost levels.

Next, learn a fast way to backtest in Event-Driven vs Vectorized 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 lessonEvent-Driven vs Vectorized BacktestingVectorised backtests compute signals and returns for all dates at once using arrays. Learn how they work, a pandas example, their speed advantages and their traps.

Mentioned in