Skip to main content

Quant Analytics: from scratch to pro · Backtesting done right · Intermediate

Costs in a backtest: spread, commission, slippage, funding

Every trade pays the spread, a commission, some slippage and, for leveraged or borrowed positions, a financing charge. A backtest that leaves these out overstates the edge, and the more often a rule trades, the larger the error.

4 min read Reviewed Revision 1

In this lesson

  • List the four cost components of a trade and compute a round-trip cost
  • Compare a gross edge per trade with the cost per trade
  • Show how trading frequency multiplies the cost drag
  • Add a financing cost for a position held over several days

Read first: What a backtest is, and what it is not, Spreads and trading costs

Share of capital lost to a 0.24% round-trip cost, by trades a year

0% 10% 20% 30% 40% 50% 02060100200250 Round trips per year
Capital lost to costs. Computed from the formula with a round-trip cost of 0.24%. The curve shows the loss from costs alone, before any gross edge, for a rule that trades more or less often.

Worked numbers

Each result is recomputed from the formula shown.

WhatFormulaResult
spread as a share of the price0.04 / 500.08%
round-trip commission2 * 0.00050.10%
round-trip slippage2 * 0.00030.06%
total round-trip costspread_pct + comm + slip0.24%
gross edge per trade0.00350.35%
net edge per tradegross_edge - rt_cost0.11%
gross edge over 100 trades, added100 * gross_edge35%
net edge over 100 trades, added100 * net_edge11%
compounded cost drag over 100 round trips1 - (1 - rt_cost)**10021.4%
compounded cost drag over 200 round trips1 - (1 - rt_cost)**20038%
financing per day at 3% a year0.03 / 3650.0082%
financing over 10 days10 * 0.03 / 3650.082%

Check yourself

A share is quoted 49.98 bid, 50.02 ask. What is the spread as a share of the price?

The spread is 0.04. Against a price of 50 that is 0.04 / 50 = 0.08%. A buyer who sells straight away loses about this amount.

Commission is 0.05% per side and slippage 0.03% per side. With the 0.08% spread, what is the round-trip cost?

Commission 2 x 0.05% = 0.10%. Slippage 2 x 0.03% = 0.06%. Total 0.08% + 0.10% + 0.06% = 0.24%.

A rule earns 0.35% per trade before costs. What does it earn after the round-trip cost above?

0.35% - 0.24% = 0.11% per trade. Costs took about two thirds of the edge.

A position borrowed at an annual financing rate of 3% is held for 10 days. What is the charge?

3% / 365 per day, times 10, is 0.082% of the position. Use the day-count the broker uses, and charge weekends.

Key terms

SlippageSpreadBacktest

Sources

Informational content. Not investment advice.