Skip to main content
AI Fin Hub

Guide, in Market Microstructure

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.

9-minute read. Published May 26, 2026. By AI Fin Hub Research.

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 Execution Simulator: Estimate execution cost in closed form — square-root permanent impact, linear temporary impact, half-spread, and a latency-drift band. See the slippage a naive backtest hides.

  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 Order Book Replay Visualizer: Drop a Level-2 snapshot CSV and replay the book snapshot by snapshot. Animated depth bars, best bid/ask, spread and imbalance. Understand microstructure before.

  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 Statistical Arbitrage Capacity Calculator: Maximum strategy AUM from alpha, slippage, fees, daily volume and volatility, and signal half-life. Square-root impact closed-form.

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.

Run the numbers next

  • Comparators Broker API Comparator

    Alpaca vs IBKR vs Tradier vs Schwab vs Robinhood — compare auth, rate limits, order types, market data, MCP, and fees before wiring a line of code.

Questions people ask next

What is the difference between temporary and permanent market impact?

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.

Why is square-root impact the common model?

Empirical studies across many markets find that the price move caused by an order scales roughly with the square root of the order size relative to daily volume, rather than linearly. The intuition is that liquidity is replenished as you trade, so larger orders face diminishing marginal impact per share. The square-root law is a robust empirical regularity used widely for execution cost estimation, though the exact coefficient varies by market.

How do I estimate slippage if I have no live trading data?

Start from observable inputs: the typical spread for the instrument, its average traded volume, and your intended participation rate. Charge the spread, then apply a temporary-impact term proportional to participation and a permanent-impact term proportional to the square root of size over volume. Be conservative, because underestimating slippage is the error that loses money. Once you have live fills, calibrate the model to them.

Does slippage matter for low-frequency strategies?

Less than for fast ones, but it is never zero. A monthly rebalancing strategy trades infrequently, so spread and latency costs are small relative to holding-period returns. But if it trades large size in illiquid names, permanent impact can still bite. The rule is to scale the cost model to the strategy: frequency drives spread and latency cost, size relative to volume drives impact cost.

Sources

  1. Direct Estimation of Equity Market Impact , Almgren, Thum, Hauptmann, Li, Risk (2005)
  2. Optimal Execution of Portfolio Transactions , Almgren and Chriss, Journal of Risk (2000)

Keep the topic connected

  • Learn Slippage

    Slippage as the gap between expected and executed price: the components (spread, market impact, latency), and how to model each in a backtest.

  • Learn Bid-Ask Spread

    Bid-ask spread defined: quoted vs effective vs realized spread, why the touch isn't the cost you actually pay, and how to measure each.

  • Learn Order Book Imbalance

    Order book imbalance: definition, the depth-weighting choice that changes everything, and why it predicts short-horizon price moves more than fundamentals.

  • Learn Maker-Taker

    Maker-taker fee model: makers get a rebate, takers pay. Why the model exists, what it incentivizes, and how to size up real net cost.