Skip to main content

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

Look-ahead bias and other leaks into a backtest

A backtest leaks when the rule uses information that was not yet available at the time of the trade. Leaks are the most common reason a backtest looks excellent and the live result does not. This lesson shows the main forms and a test for each.

4 min read Reviewed Revision 1

In this lesson

  • Define look-ahead bias and give four ways it enters a backtest
  • Align a signal and a trade so that the signal uses only past information
  • Quantify how large a one-bar leak can be on a small example
  • Apply a lag test and a point-in-time check to find leaks

Read first: What a backtest is, and what it is not, Clean data: timestamps, time zones, DST and survivorship

Worked numbers

Each result is recomputed from the formula shown.

WhatFormulaResult
leaked rule, return on positive days only1.01 * 1.015 * 1.02 - 14.57%
honest rule, lagged by one day0.98 * 0.99 - 12.98%
value of the leak(leak_ret - honest_ret) * 1007.55

Check yourself

A rule holds a position on day t if the return on day t is positive. Why is the backtest wrong?

The sign of day t is known only when day t ends. Holding during day t on that basis uses the future. The position must come from day t-1 or earlier.

Daily returns are +1%, -2%, +1.5%, -1%, +2%. What does the leaked rule earn, and what does the honest one (hold the next day if today was positive) earn?

Leaked: 1.01 x 1.015 x 1.02 - 1 = 4.57%. Honest: it holds on days 2 and 4 only, 0.98 x 0.99 - 1 = a loss of 2.98%. The leak is worth 7.55 percentage points.

A test uses the whole sample's average and standard deviation to standardise a signal. What is the leak?

Early dates are scaled with numbers computed from later data. Use only an expanding or rolling window that ends at the date of the decision.

A fundamental figure for a quarter appears in the database under the quarter end date. Why does that leak?

The company reported weeks later and may have revised it. The rule saw the number before the world did. Use the date it became known, and the figure as first published.

Key terms

Look-ahead biasPoint-in-time dataSurvivorship bias

Sources

  • Advances in Financial Machine Learning. Wiley (Marcos López de Prado), 2018. Accessed 9 Nov 2026
  • The Econometrics of Financial Markets. Princeton University Press (John Y. Campbell, Andrew W. Lo, A. Craig MacKinlay), 1997. Accessed 9 Nov 2026

Informational content. Not investment advice.