Skip to content
Learning path Silver Repeatable method

Transaction costs in backtests

Causal modelling of the costs that separate a theoretical strategy from implementation: commissions, spread, impact, delays, partial fills, borrow, funding, roll and capacity.

Who this is for — Anyone moving from theoretical signals to simulated orders who needs to know whether the edge survives implementation. Subtracting a fixed commission is not enough when spread, impact, borrow, funding and fill probability change with instrument, time and quantity.

Transaction costs in backtests are the rules by which a simulation turns a theoretical decision into a plausible net result. They include explicit costs, implicit frictions, holding costs and missed executions. The model must be causal: it uses only quotes, volumes, fees and availability that could have been known when the order would have been submitted.

In simple terms — The signal says what one would like to buy or sell. The cost model asks whether, when, how much and at what price it would actually have been possible to do so.

From gross result to net and capacityEach friction has its own benchmark, scale and market dependence. Invented index with gross=100; teaching values do not represent a real strategy.From gross result to net and capacityEach friction has its own benchmark, scale and market dependenceInvented index with gross=100; teaching values do not represent a real strategy.1Gross1002Commissions−43Spread−64Slippage−75Impact−106Net / capacity73Cyclepedia · conditional teaching diagram, not a forecast or promise
As quantity increases, costs and fills do not necessarily remain linear: capacity belongs to the implemented strategy.

From signal to net result

A useful decomposition is:

net result = theoretical result − explicit costs − spread − impact − delay/opportunity cost − holding costs − roll costs

Not every component can be observed separately, and the formula does not prevent overlaps. For example, comparing a fill with the midpoint quote may already include part of the spread and impact; subtracting them again would double count them. A benchmark, timestamps and conventions must come before the number.

Component What it represents Main drivers
Commissions and fees applicable broker, venue, clearing, exchange and tax charges instrument, market, volume, fee schedule
Spread cost of crossing the bid/ask difference liquidity, time of day, volatility, order type
Slippage difference between the fill and the stated benchmark latency, gaps, depth, event sequence
Market impact price movement associated with one's own demand for liquidity size, participation, urgency, volatility, resilience
Delay and opportunity cost movement while the order waits or remains incomplete duration, limit, competition, signal decay
Partial fill and non-fill executed quantity below the requested quantity priority, depth, cancellations, venue
Borrow securities lending, availability, recalls and short fees lending demand, supply, security specificity
Funding and margin financing positions, collateral and leverage rate, currency, haircut, duration, intermediary
Roll and basis closing and reopening contracts or exposures curve, calendar, spread between maturities, liquidity

Other elements may include currency conversion, stamp duty or tax treatment. They should enter only where relevant and under a documented rule.


Why a fixed cost is not universal

An assumption of “one tick per trade” can be a teaching scenario, not a market property. The same order changes cost between an auction and continuous trading, normal conditions and stress, a liquid security and a micro-cap, or a passive and an aggressive order. Even the sign of slippage may be favourable or unfavourable relative to the benchmark; that does not make impact free or guarantee that the improvement can be repeated.

The model should therefore depend, when the data permit, on:

  • order quantity and notional value;
  • available volume and participation rate;
  • observable spread and depth;
  • volatility and time regime;
  • side, order type, urgency and duration;
  • venue, currency and asset class;
  • borrow, funding and contract state.

A simple function that increases with participation may be more transparent than a complex, uncalibrated simulation. Complexity should follow the data, not precede them.


Causal orders and fills

The correct chain is: available data → signal → order → market interaction → fill → position. A daily OHLC bar does not reveal the intraday sequence or the quantity available. If both a stop and a target are crossed within the same bar, the backtest cannot retrospectively choose the favourable outcome. It needs more granular data or a stated conservative rule.

For a limit order, “price touched” does not automatically mean filled: orders may be ahead in the queue or volume may be insufficient. For a market order, the price is not guaranteed and the order may cross several levels. Latency and partial fills change quantity, risk and subsequent signals. These constraints must respect the pipeline described in data leakage and look-ahead bias.


Strategy capacity

Capacity is the scale beyond which net return, risk or fidelity to the signal deteriorates materially. It is not a fixed amount valid forever. It depends on assets, turnover, concentration, horizon, crowding and execution method.

A practical check reruns the test at several levels of capital or participation. At each level it records:

Output Why it matters
requested and executed quantity separates desired exposure from the position obtained
percentage of volume measures relative pressure on the market
average and marginal cost shows scale non-linearity
incomplete orders identifies signals that cannot be implemented
net return and drawdown measures economic deterioration
liquidation time connects capacity with exit risk

Capacity is not demonstrated merely by comparing average size with average volume: stress days, concentrated instruments and simultaneous exits may dominate the risk.


Modelling protocol

  1. Define the benchmark. State the price and timestamp against which the fill is measured.
  2. Generate explicit orders. Quantity, side, type, limit, duration and logical priority must derive from the signal.
  3. Align calendar and data. Use quotes, volumes and contracts available point in time after the signal.
  4. Apply verifiable explicit costs. Version fee schedules, regime changes and currency.
  5. Model spread and impact without duplication. State the benchmark and the chosen function.
  6. Allow partial fills and non-fills. The position must use the quantities actually simulated.
  7. Add relevant carry. Borrow, funding and margin accrue over time; the roll follows contracts and calendars.
  8. Calibrate against reality when possible. Compare live or paper fills with forecasts by order class.
  9. Run scenarios. Base, favourable and severe cases should vary observable drivers, not multipliers presented as laws.
  10. Test multiple scales. Publish the cost and net-return curve against capital or participation.
  11. Freeze the model before OOS. Parameters and rules used in the out-of-sample evaluation must not be adapted to its result.

Illustrative example — A signal requests 20,000 units. The simulator finds a variable spread, permits 12,000 units in the first interval and 5,000 in the next; the remaining 3,000 expire. It subtracts commissions from executed quantities, estimates impact as a function of participation and applies funding only during the holding period. When capital doubles, quantity is not simply doubled at the same price: participation increases and the test recalculates fills and cost. The figures are purely illustrative.


Limitations and communication

Counterfactual impact cannot be observed precisely: the market without one's own order cannot be seen. Models calibrated on quiet periods may fail under stress; quote data do not always reconstruct queue position; historical borrow and funding data may be incomplete. A backtest should therefore not present cost as a point truth, but as a conditional estimate with assumptions, intervals and scenarios.

Gross return remains useful for studying the signal; net return is needed to assess implementability. Publishing both, together with turnover, quantities, fill rate and capacity, makes visible where the result is created or lost.


Sources