Education

Backtest Costs — Commission, Slippage and the Fill Model That Decides the Verdict

A backtest without costs does not measure a strategy. It measures a strategy plus a subsidy, because the market charges on every round trip while the test quietly pays nothing. Costs are not a settings detail; they are a per-trade tax that compounds with turnover, and two of them — fixed fees and fill assumptions — decide whether a small edge survives at all.

This article walks the full stack of what trading costs, how each one should be modelled, and why every metric must be computed on the net curve. The goal is narrow: a Sharpe, a drawdown and a return that already had the market's share removed.

The cost stack

Six charges apply to a typical retail round trip. They accumulate, and a test that omits any one of them flatters the result by exactly that amount.

CostCharged forFixed or proportionalWhat a naive test misses
CommissionPlacing the orderPer order, or basis points of notionalMinimum ticket sizes that punish small accounts
SpreadCrossing the bid-ask instead of restingProportional to price, fixed in ticksWidening at the open, the close and thin hours
SlippagePrice moved between signal and fillProportional, grows with volatility and sizeThat it scales with your order, not with the signal
Market impactYour size consumes available volumeSub-linear in size (square-root law)Partial fills that spill into later bars
Borrow and financingShort borrow, futures funding, margin, rollCarry over the holding periodLong holds and roll dates as real trades
Currency conversionTrading an instrument quoted in another currencyProportional, charged per conversionConverting twice per round trip

The carry row is the one most often skipped. A perpetual future charges funding at each funding event; a futures roll is not a price splice but a real close-and-open with a spread and a commission on both legs; a short stock position pays a borrow rate for as long as it is held. Missing funding is the same class of error as missing commission — the test simply ran a cheaper instrument than the one you will trade.

Fixed vs proportional: why turnover kills

Proportional costs scale with position size, so a bigger account pays more money but the same percentage. Fixed costs do not scale: a flat commission is a percentage of a small position and a rounding error on a large one, which means fixed fees punish exactly the same behaviour they should discourage — trading too often, too small.

The arithmetic is blunt. Take a strategy whose gross edge is 0.01% per trade against a round-trip cost of 0.05% — commission, half-spread each way and a tick of slippage. Every trade loses 0.04% net before anything else happens. There is no holding period, no market regime and no parameter setting that rescues a negative expectancy; there is only the possibility of fewer trades, if the signal quality allows it.

Worked example: strategy A makes 20 trades a year with a gross edge of 0.5% per trade, paying the same 0.05% round trip. Net edge is 0.45%, the year keeps 9% of notional, and costs ate 10% of the gross profit. Strategy B makes 400 trades a year with a gross edge of 0.08%. After the same 0.05%, net edge is 0.03%, the year keeps 12%, and costs ate 62% of the gross profit. B is busier, looks more sophisticated on an equity chart, and surrenders most of itself to the fee schedule.

This is why breakeven_commission — the fee level at which the strategy reaches zero — is often faster to read than the whole statistics table. If the answer is "a commission you will never pay", the strategy is robust; if it is "about what my broker charges", the backtest was a subsidy.

Fill model honesty

The fill model decides what the test is even allowed to see. It is the single largest source of fake edge in retail backtests, and it is not a matter of degree.

Fill modelWhat it assumesWhat it leaks
Same-bar fillYou trade the price of the bar that produced the signalLook-ahead: the order uses information at the moment it appears
Fill at signal priceThe fill equals the close, with no adverse moveA free option on perfect execution
Next-bar fillOrder sent after the bar closes, filled at the next openNothing structural — latency still missing, which is honest
Next-open with gap rulesSame, plus stops and limits resolved against the opening priceNothing structural; this is the conservative default

Same-bar fill is look-ahead in its purest form: the signal reads bar i and the position is filled at a price from bar i that no participant could have transacted at when the rule decided. Filling at the signal price is the same sin in quieter clothes. The fix costs performance on paper — every honest fill model makes backtests look worse — and that cost is the price of the number being real.

Next-bar fill deserves a precise description. A market order fills at the open of the following bar plus slippage; a limit order that price crossed fills at the limit, but if the bar opened beyond it, the fill is at the open, in the market's favour and not yours; a stop order that price touched fills at the stop plus slippage, with one exception below.

Gaps through stops fill at the next open

The exception is the one that survives into live trading unchanged. A stop resting at 100, in a position entered at 105 with a planned risk of 4.8%, becomes worthless as protection for the weekend if the market opens at 94. The order does not fill at 100. It fills at 94, so the loss is 10.5% instead of the 4.8% on the plan — a 5.7-point difference produced by a single gap.

Backtests that fill stops at the stop price manufacture risk control that the market does not provide, and the discrepancy is not visible in the win rate. It is visible in the tail of the loss distribution, which is where drawdowns come from — see max drawdown explained for why the tail, not the average, defines the metric. An honest engine fills the gapped stop at the opening price and lets the loss land where the market put it.

Net before any metric

Every published metric — Sharpe, return, drawdown, win rate — must be computed on the curve after costs. A Sharpe computed on a gross curve is fiction: it describes a portfolio that trades for free, which does not exist, so the number cannot be compared to any live result or to any threshold.

Worked example. A strategy trades once per session, 250 round trips a year. Its daily returns before costs have a mean of 0.14% and a standard deviation of 1.24%. Gross Sharpe is 0.14 / 1.24 × √250 ≈ 1.8. Now charge 0.07% per round trip — 0.02% commission, 0.02% spread, 0.03% slippage — paid on 250 trades, which is 17.5% of notional a year against a gross 35%.

The daily mean falls from 0.14% to 0.07% while volatility barely moves, because a fixed-per-trade cost shifts the mean and barely touches the variance. Net Sharpe is 0.07 / 1.24 × √250 ≈ 0.9. One honest fill of the cost stack halved the ratio, from 1.8 to 0.9, and the cost drag is 50% of gross profit — a strategy that looks like a clear pass on the gross curve is a marginal one on the net curve. The same discipline applies to the threshold next to it: a net Sharpe is only meaningful read against the number of trials behind it (how many backtests is too many, what the Sharpe ratio measures).

Estimating slippage honestly

Slippage is the cost traders argue about least and model worst, because it depends on the instrument and the timeframe rather than on the strategy. Four rules keep the estimate defensible.

The spread is the floor. Even with zero impact, a market order crosses half the spread on entry and half on exit. Where historical bid-ask exists, use it; where it does not, derive it from intraday volatility, and widen it at session boundaries and in the minutes around scheduled macro events, because that is when your fill actually degrades.

Scale with size, not with confidence. A standard retail approximation is a square-root impact model: slippage grows with bar volatility and with the square root of your order size divided by bar volume, with the coefficient calibrated per market — never tuned per strategy, or the estimate becomes another parameter to overfit.

Cap the order against volume. If your order would consume more than a fixed share of the bar, the excess fills on later bars or cancels. That cancellation is data: a high share of unfilled signals means the test traded a different system than the one you described.

Calibrate against real fills. Your own broker statements or paper fills on a live feed are the only external check. Compare assumed against actual for a month, in basis points per round trip, and feed the difference back into the cost profile. Pessimistic profiles should be the default; optimistic ones are usable but must be flagged in the report, so nobody mistakes them for the number they will live with.

What a judging report shows

A report that respects costs prints them, not just the outcome. Three lines do the work: the metric net of costs, a cost_drag_pct line stating how much of the year the market ate, and breakeven_commission stating how much fee the strategy can carry. From our engine's output format as an interface example — gross return 19.4%, cost drag 6.8%, net return 12.6% — the drag line alone tells a reader whether the edge belongs to the strategy or to the fee schedule. These figures are interface examples from documentation, not results of a live account.

With those lines visible, cost questions stop being philosophical. Doubling turnover doubles the drag, and an instrument with twice the spread needs twice the edge to clear the same bar.

How to check your own backtest

  1. Name every cost your broker charges — commission, spread, borrow or funding, conversion — and confirm each appears in the run's cost profile.
  2. Confirm the fill model is next-open with gap-aware stops, and never the close of the signal bar.
  3. Ask for the metric net of costs, plus the cost drag as a percentage of gross profit.
  4. Compute the breakeven commission. If it sits near your real fee schedule, the strategy has no margin of safety.
  5. Read the round-trip cost against the per-trade edge: 0.05% of cost against 0.01% of edge is a decision, not a detail.
  6. Check the unfilled-signal share. It tells you whether your size fits the instrument's volume.
  7. Re-run with a pessimistic cost profile. If the verdict flips, the strategy was trading on optimism.

The Replay simulator applies a named cost profile to every fill and prints the drag next to the metrics, so the net number is the one you start from — run your own case at /chart, and read the protocol side of the same question in out-of-sample testing and backtest vs live trading.