Skip to main content

Data and machine learning · 11 min read

Backtesting without look-ahead bias

How a backtest manufactures profits from noise: look-ahead, survivorship, and a checklist for the rest.

Before you start

  • Time series with pandas
  • Hypothesis tests and false discoveries

By the end you'll be able to

  • Explain why a backtest may only use information available at each decision
  • Find and fix look-ahead bias in pandas code
  • Recognise survivorship bias and the data needed to avoid it
  • Review a backtest against a checklist of common biases

A backtest answers one question: if I had followed these rules in the past, what would have happened? It can only answer honestly if, at every step, it uses nothing that wasn't known at that moment. Breaking that rule doesn't make a backtest a little optimistic; it can manufacture a spectacular strategy out of pure noise. This lesson shows the two most common ways it happens and a checklist for catching the rest.

TermMeaning
look-ahead biasUsing information in a decision before it was available
survivorship biasBuilding the universe from what exists today, dropping what disappeared
point-in-time dataData as it was known on each date, before later corrections or restatements
equity curveThe growth of money invested in the strategy over time
Sharpe ratioAnnualised mean return over volatility

The rest of this lesson needs lifetime access

It will be part of lifetime access, which is coming soon: every lesson in all four tracks, including lessons added later, for one payment.

See pricing

Already have access? Sign in