Model fees and slippage in a backtest

Keep a reference price, simulated fill price and fee for each execution. The reference may be the midpoint when the order decision occurs. Fill prices can model spread, delay and depth. Compute explicit commissions on actual simulated notional per fill.

Reconcile a round trip

Use 10 units, reference prices of 100 on entry and 101 on exit, and a 0.10% fee on each side. With adverse price changes of 0.10 per unit, the fills are 100.10 and 100.90.

Item Amount
Ideal reference-price profit 10.00
Profit at simulated fills before fees 8.00
Entry commission on 1,001 1.001
Exit commission on 1,009 1.009
Net profit 5.99

The strategy loses 4.01 to simulated friction compared with ideal fills. If your fill price already models the ask on buys and the bid on sells, count the spread through that price. Keep costs in one quote currency and tag modeled versus measured inputs.

Sweep the assumptions

Use at least a low, base and high cost scenario. Keep signals and market-data windows fixed and record when a cost change alters available cash and future size. A strategy with more turnover can lose more under the same fee change. Report volume, fill count and costs next to net performance.

Single-fill cost calculator · Next-open versus close timing