Skip to main content

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

What a backtest is, and what it is not

A backtest replays a rule on past data to see what it would have done. It is one simulated path, built with hindsight on the table. It can reject weak ideas well; it cannot prove that an idea works.

3 min read Reviewed Revision 1

In this lesson

  • Explain what a backtest computes and which parts are simulated
  • Turn a list of trade results into an equity curve and a total return
  • Say why a backtest is evidence against an idea more than evidence for it
  • Compare a backtest with the right benchmark, after costs

Read first: Returns: simple, log and compounded, Risk and return

Worked numbers

Each result is recomputed from the formula shown.

WhatFormulaResult
starting equity1000010,000
final equity before costsstart_eq * 1.02 * 0.99 * 1.03 * 0.98 * 1.01510,346
total return before costsgross_eq / start_eq - 13.46%
final equity with 0.2% cost per tradestart_eq * (1.02 - 0.002) * (0.99 - 0.002) * (1.03 - 0.002) * (0.98 - 0.002) * (1.015 - 0.002)10,243
total return after costsnet_eq / start_eq - 12.43%
return lost to costsgross_ret - net_ret1.02
buy-and-hold return, price 100 to 104104/100 - 14%

Check yourself

A rule takes five trades with results +2%, -1%, +3%, -2% and +1.5%. Starting from 10,000, what is the final equity before costs?

Multiply, do not add: 10,000 x 1.02 x 0.99 x 1.03 x 0.98 x 1.015 = 10,346, a total return of 3.46%.

The same trades each lose 0.2% to costs. What is the total return now?

Each result falls by 0.2 points: 1.018 x 0.988 x 1.028 x 0.978 x 1.013 gives 10,243, or 2.43%. Costs removed 1.02 percentage points from five trades.

The market itself went from 100 to 104 over the same period. Did the rule add value?

Not on these numbers. Holding returned 4%, the rule 2.43% after costs. The right comparison is with holding the asset, over the same dates, on the same basis.

A backtest looks good. Why is that not proof?

It is one path, tested on data that the designer had already seen. Many variants may have been tried, and a good-looking result among them is expected by chance. It is a reason to test further.

Key terms

BacktestOut-of-sampleSlippage

Sources

Informational content. Not investment advice.