Appearance

Personalize your experience

Mode
Accent Color
Direction
Execution Modelling

Execution Modelling

Backtesting

Commission, slippage, spread and fill assumptions — the difference between a backtest that means something and one that flatters. Costs are where most strategies actually die.

Costs are not a detail

A zero-cost backtest is not an approximation, it is a different . Costs are charged per trade, so they scale with frequency while the edge does not — which means the same signal can be excellent at 50 a year and unprofitable at 600.

18% GROSS RETURN, 0.03% COMMISSION PER SIDEnet keptpaid in commission50 trades / yr+15.0%cost 3.0%200 trades / yr+6.0%cost 12.0%600 trades / yr−18%cost 36.0%2000 trades / yr−102%cost 120.0%the same edge, four frequencies — a zero-cost backtest hides all of this
One 18% gross edge, four trade frequencies, 0.03% commission per side. The last row is a losing strategy.
!
Caution:Read the bottom row. Two thousand trips a year at 0.03% per side costs 120% of capital in commission — the is unrunnable regardless of how good the signal is. A backtest with costs at zero shows the same signal as a comfortable winner, and nothing on the page hints otherwise.

Commission

The straightforward cost, and the easy one to get : your broker publishes it. What people get wrong is applying it per side rather than per trade, and forgetting the components.

ComponentTypeDescription
Brokerage% or flatThe headline charge. Often a with a per-order cap, which makes the effective rate depend on order size.
Exchange fees% but per-trade, so they matter at frequency.
Statutory charges%Transaction tax, duty, regulatory fees. Jurisdiction-specific and non-negotiable.
GST / VAT% of brokerageCharged on the brokerage rather than on turnover, so it scales with the brokerage component.
effective round-trip cost
// what to actually enter as "commission" in the backtestfunction roundTripCostPct(orderValue: number) {  const brokeragePerSide = Math.min(orderValue * 0.0003, 20);  // 0.03%, capped  const exchangePerSide  = orderValue * 0.0000325;  const statutoryPerSide = orderValue * 0.0001;  const gst              = brokeragePerSide * 0.18;  const perSide = brokeragePerSide + exchangePerSide + statutoryPerSide + gst;  return (perSide * 2) / orderValue * 100;   // both sides, as a percentage}// note the cap: at large order sizes the effective rate falls,// so a strategy's cost profile depends on its position sizeroundTripCostPct(50_000);    // ≈ 0.13%roundTripCostPct(500_000);   // ≈ 0.04%
★
Pro tip:The per-order cap matters more than it looks. A trading positions pays a much higher effective than the same strategy trading large ones, so a backtest at one position size does not tell you the cost profile at another. Re-check costs whenever you change .

Slippage

Slippage is the gap between the price the signal fired at and the price you actually got. Unlike commission it is not published — it has to be measured, and it varies by , , time of day and market condition. It is conventionally quoted in basis points, which keeps it comparable between instruments at different price levels.

WHAT THE BACKTEST ASSUMES AND WHAT THE MARKET DOES100.00entry98.00stop levelbacktest fills here97.85typical fill−0.15 slippage94.20gap fill−3.80 slippage−2.0%−5.8%a stop is an instruction to trade at a level, not a guarantee of a price — gaps ignore it entirely
A 2% stop, three outcomes. The level is an instruction; the fill is whatever the market offers.
SourceDescription
SpreadA market buy pays the ask and a market sell receives the bid, so crossing the spread is a guaranteed cost on every . On liquid instruments it is a ; on illiquid it can exceed the edge.
Queue positionA at the is behind everyone already resting there. The backtest it when price reaches the level; reality may not fill it at all.
LatencyTime between the bar closing and the order arriving. Price moves in that , and it moves against you more often than not — the signal fired because price was moving.
Market impact orders consume the book and move the price. Negligible at retail size on liquid instruments; not negligible on thin ones.
GapsThe worst case, and the one no slippage setting captures. Price jumps past the stop and wherever the market reopens.
!
Caution:Slippage is asymmetric. It costs you on entries and exits, and it is worst precisely when you most need a fill — on a stop during a fast move, which is when spreads widen and liquidity withdraws. Modelling it as a symmetric average understates the tail.

Fill assumptions

The engine at the , completely, at one price. Each part of that is a simplification worth knowing.

ONE BAR, AND THE PATH THE BACKTEST CANNOT SEEhigh 103.2open 102.1close 99.4low 97.6same OHLCboth paths produce this identical candlea stop at 98 and a target at 103 are both touched — which one filled first is unknowable from the bar
Two intra-bar paths, one identical candle. If both a stop and a target sit inside the bar, the backtest cannot know which was reached first.
AssumptionDescription
Fill at bar close, the order is placed after the close and at the next available price. On a fast-moving bar those differ materially.
Complete fillNo . limit orders in a thin book fill partially, leaving a position size the did not for.
Single priceA order consuming several book levels at a volume-weighted average worse than the .
Stop fills at the levelThe most optimistic assumption in the engine. A stop is a market order once triggered, so it at whatever is available — and a gap ignores the level entirely.
!
Caution:If a 's stop and target are both inside typical bar range, it is not properly testable on that timeframe. The engine resolves the ambiguity by convention rather than by evidence, and roughly half of those are recorded as the wrong outcome. Either widen the levels or test on a finer timeframe.

Setting realistic values

Instrument classTypeDescription
Index futures (liquid)0.02–0.05% cost, 1–2 ticks slippageNIFTY, BANKNIFTY. The friendliest case, and where tight spreads make higher frequency viable.
Large-cap equity0.05–0.15% cost, 2–5 ticksCash equity attracts more statutory charges than derivatives in many jurisdictions.
Mid and small-cap equity0.15–0.4% cost, 5–20 ticksWider spreads and real . Frequency strategies rarely survive here.
Options (near the money)0.1–0.3% cost, wide spreadsSpreads dominate. Model them explicitly rather than folding them into a slippage average.
Options (far OTM)spread frequently exceeds the edgeA spread of several percent of makes most systematic strategies uneconomic.
Crypto (major pairs)0.05–0.2% cost, low slippageDeep books on major pairs; funding costs apply to perpetuals and are easy to forget.
★
Pro tip:When uncertain, be pessimistic. A that survives twice your slippage estimate is one you can deploy; a strategy that needs your optimistic estimate to work will discover the real number with capital. Overestimating costs loses you a marginal strategy — underestimating them loses you money.

Reconciling live against backtest

When diverge, the cause is measurable rather than mysterious. Work through it in this order.

  • realised slippage from twenty against the bar closes they should have executed at. Feed the mean back into the backtest and re-run. This usually closes most of the gap.
  • Check the exit-reason mix. If shows more stops than the backtest did, the stop is being hit intra-bar in a way the replay could not see.
  • trade counts. Fewer at feed gaps or latency causing missed signals; more points at a configuration difference.
  • Check average position size. If sizes are smaller, orders are filling partially, and every P&L figure scales accordingly.
  • Whatever residue remains after those four is timing, and timing is not by adjusting cost parameters — it is fixed by trading a slower timeframe or accepting the .
ℹ
Note:None of this indicates a broken . The same code evaluates conditions in both places, so a divergence is always , costs, or timing. Knowing that narrows the investigation to four measurable things instead of leaving it open-ended.

See also

Related articles

  • Market Impact

    Trading / Order Book / Views

    The slippage curve: what a market order of any size would cost right now.

  • Step 7 — Strategy Testing

    Automation / Strategy Builder / Wizard Steps

    The testing step offers three modes, each answering different questions about strategy behavior. Use all three in sequence: backtest to validate logic,…

  • From Backtest to Live

    Backtesting / Going Live

    The staged path from a validated backtest to full size, what each stage can detect that the previous one cannot, and the monitoring that tells you when to stop.

  • Depth Chart

    Trading / Order Book

    Cumulative depth on both sides of the book, aligned to the ladder in every position, with big-order bubbles, liquidity flashes, prints and a slippage readout.

  • SFO Capital, Orders & Risk

    Automation / Predefined Strategies / SFO Wheel

    A put is only sold if strike × quantity fits within max capital × (1 − reserve). Auto-filled from the grid until edited.

  • Spacing & Targets

    Automation / Predefined Strategies / Wizard Steps

    Spread sets how far apart the rungs are, target sets how far each fill has to travel to book profit, and buffer keeps refills from becoming market orders.

  • Spread Timeline

    Trading / Order Book / Views

    Best bid, best ask, micro-price and spread over time, with prints — the touch as a time series.

  • Step 2 — Tagging

    Automation / Strategy Builder / Wizard Steps

    Optional. Client order ID templates, signal-level metadata and order linking — the machinery that makes live orders reconcilable against broker statements.

  • Backtesting in Python and C++

    Backtesting / SDKs

    The quatick Python package and the header-only C++ library let you import indicators, backtest on your own machine and send the same file to Quatick.…

Browse all knowledge base articles →