Skip to main content
aifinhub
Market Microstructure Guide

How to Backtest with Realistic Slippage

The fastest way to turn a winning backtest into a losing strategy is to assume you trade for free at the mid price. Real fills pay the spread, move the market, and arrive late. For small, patient strategies the gap is modest; for fast or large ones it can erase the entire edge. The cost components a credible backtest must include, and how to estimate each, are covered below so paper returns survive contact with live execution.

By AI Fin Hub Research · AI Fin Hub Team

On This Page

Before You Start

Set up the inputs that make the next steps easier

A strategy's intended order sizes and trading frequency.
An estimate of the typical bid-ask spread and average traded volume for the instruments you trade.
A view on how quickly you can act on a signal, since latency determines what price you actually get.

Guide Steps

Move through it in order

Each step focuses on one decision so you can keep momentum without losing the thread.

  1. 1

    Charge the spread on every fill

    The most basic and unavoidable cost is the bid-ask spread: a buy fills near the ask, a sell near the bid, so a round trip pays roughly the full spread before any impact. Backtests that fill at the mid price quietly hand you half the spread for free on every trade, which compounds with frequency. Start by charging at least the half-spread per side, using a spread estimate appropriate to the instrument and time of day.

    Spreads widen at the open, the close, and during news. A flat average spread understates cost for strategies that trade in exactly those windows.

    Use The ToolPlaygrounds

    Execution Simulator

    Model realistic order fills — square-root market impact, linear temporary impact, latency jitter, partial fills, and queue position. See the real cost.

    ToolOpen ->
  2. 2

    Add temporary market impact

    When you take liquidity, your own order pushes the price against you, and this temporary impact grows with how aggressively you trade relative to available volume. A common model makes temporary impact scale linearly with your participation rate. The larger your order relative to the volume in the window, the worse the average fill. This is the cost that turns a strategy that works on paper at small size into one that cannot scale.

    Model impact as a function of size, not a flat fee. A fixed cost per trade hides exactly the size-dependence that limits capacity.

  3. 3

    Account for permanent impact

    Beyond the temporary push that decays after you stop trading, large orders also move the price permanently by revealing information to the market. Permanent impact commonly scales with the square root of order size relative to daily volume. It does not decay, so it raises the cost basis of the whole position. For institutional-size strategies this term dominates and is the main reason capacity is finite.

    Square-root permanent impact means doubling your size does not double the cost per share, but it does keep raising it. There is no size at which impact stops mattering.

  4. 4

    Model latency between signal and fill

    A signal computed at one price does not fill at that price; time passes, and the market moves. The faster your strategy and the more it competes on speed, the more this latency cost matters, because the edge you saw may be gone by the time you act. Add a realistic delay between signal and execution in the backtest and fill at the price that prevailed then, not the price that triggered the signal.

    If your edge disappears once you add a realistic latency delay, it was a latency-arbitrage edge you cannot capture without the infrastructure to win the race.

  5. 5

    Model partial fills and queue position

    Resting limit orders do not always fill, and when they do you wait in a queue behind earlier orders at the same price. A backtest that assumes every limit order fills completely and instantly overstates a maker strategy badly. Model the probability of a fill given your queue position and the volume that traded at your price, and treat unfilled orders as missed trades rather than free ones.

    Maker strategies live or die on fill probability. Assuming full fills turns adverse selection invisible: you get filled exactly when the price is about to move against you.

    Use The ToolPlaygrounds

    Order Book Replay Visualizer

    Drop a Level-2 CSV and watch the book reconstruct tick by tick. Animated depth bars, best bid/ask, spread over time. Understand microstructure before.

    ToolOpen ->
  6. 6

    Find the capacity where the edge breaks

    Put the cost components together and re-run the backtest at increasing sizes to see where the net edge goes to zero. This capacity analysis is the bottom line: it tells you the maximum size at which the strategy is still worth trading after realistic costs. An edge that exists only below a size you cannot reach is not deployable, and capacity, not raw Sharpe, is what determines how much capital a strategy can actually carry.

    Report the strategy's capacity in dollars, not just its Sharpe. A high Sharpe at trivial size is a research curiosity, not a business.

    Use The ToolCalculators

    Statistical Arbitrage Capacity Calculator

    Maximum strategy AUM from signal half-life, daily volume, slippage, fees, and target Sharpe. Square-root impact closed-form.

    ToolOpen ->

Common Mistakes

The misses that undo good inputs

1

Filling at the mid price

Real fills pay at least the half-spread per side. Mid-price fills hand the strategy free money on every trade, and the error compounds with frequency until a losing strategy looks profitable.

2

Using a flat per-trade cost regardless of size

Market impact grows with order size relative to volume. A flat fee hides the size-dependence, so the backtest looks the same at any scale and the real capacity limit stays invisible until live trading reveals it.

3

Assuming limit orders always fill

Resting orders fill probabilistically and suffer adverse selection: you tend to get filled right before the price moves against you. Assuming guaranteed fills makes a maker strategy look far better than it is.

Try These Tools

Run the numbers next

FAQ

Questions people ask next

The short answers readers usually want after the first pass.

Temporary impact is the price concession you pay for demanding liquidity quickly; it decays after you stop trading, so it affects only the fills you make in that window. Permanent impact is the lasting price move your order causes by signaling information to the market; it does not decay and raises the cost basis of the whole position. Temporary impact dominates for fast, small trades; permanent impact dominates for large institutional orders.

Sources & References

Related Content

Keep the topic connected

Planning estimates only — not financial, tax, or investment advice.