Portfolio LabKnowledgeSign inCreate account

Backtest overfitting: when the past looks too good

Advanced10 min read · updated 15 September 2026 · 9 sources

Backtest overfitting means that a strategy has been tuned to the past until it shines there. Afterwards, it fails. On top of that come biases in the data itself: funds that no longer exist are missing, and information is used that nobody had at the time. This article shows how to recognise such backtests and how to protect yourself.

The basic problem: many attempts, one winner

A backtest is a simulation: how would a rule have performed in the past? Each individual simulation is harmless. It becomes dangerous when you try out many variants (different time windows, different thresholds, different assets) and in the end show only the best one. The result then mainly measures how lucky the best of many variants was.

The best of many variants in the backtest and afterwards

Simulated: 24 random paths without drift, i.e. without any real edge. The selection is made after the backtest. Out of sample, the winner no longer has a lead.

Statistically, this is a problem of multiple testing. A single test with a 5% significance level will, for a worthless strategy, find a “significant” result by chance in 5% of cases. With many independent tests, such a chance hit becomes almost certain:

Number of independent testsProbability of at least one chance hit
15.0%
522.6%
2064.2%
10099.4%
P(at least one hit) = 1 − (1 − 0.05)^N
N
number of independent tests without a real effect

How high is the best Sharpe ratio by chance?

Bailey and López de Prado (2014) give an approximation for the expected highest Sharpe ratio among N strategies that in truth all have a Sharpe ratio of zero. It depends only on the number of trials and on the standard error of the Sharpe ratio, which for T years of data is roughly 1 / √T.

E[max SR] ≈ σ_SR × ((1 − γ) × Φ⁻¹(1 − 1/N) + γ × Φ⁻¹(1 − 1/(N × e)))
σ_SR
standard error of the Sharpe ratio, about 1 / √T for T years
γ
Euler-Mascheroni constant (≈ 0.5772)
Φ⁻¹
quantile function of the standard normal distribution
N
number of independent trials
Best Sharpe ratio from pure chance

Approximation by Bailey and López de Prado (2014) from the section above with the standard error 1 / √T. Each tenfold increase in trials raises the hurdle significantly; twice as much data lowers it only by a factor of 1 / √2, i.e. by just under 30%.

A concrete case: you test a trend rule based on a moving average and try out every window length from 2 to 24 months, i.e. 23 variants. With 20 years of data, the standard error is 0.22, and the best of 23 independent variants would reach a Sharpe ratio of around 0.44 by chance alone. The variants are, however, strongly dependent on one another (a 9-month window behaves much like a 10-month one). The effective number of independent trials is therefore smaller. Even so, the measured superiority of the best window is biased upwards.

The three classic biases

Survivorship bias: only the survivors

Databases often contain only funds and stocks that still exist today. Yet funds with poor results are more often closed or merged. If you choose from today's funds and test their past, you see a prettified world. Brown et al. (1992) show that this bias distorts not only the level of returns but also rankings and the apparent persistence of managers. Using a data set of all equity funds in existence at the time, Malkiel (1995) found that the bias was larger than earlier studies had assumed and that the funds on average lagged their benchmark portfolios.

Look-ahead bias: knowledge from the future

At every point in time, a backtest may only use what was known at that time. Typical violations: company earnings that are published only weeks after the quarter end but already enter the calculation at the quarter end; economic data in its revised rather than its originally reported version; today's index constituents applied to the past; parameters that are estimated on the entire history and then applied to that same history.

Selection and publication

Selection arises even without any trial and error of your own: the strategies that get published are the ones that worked. Fund providers prefer to launch new products on themes that have done well recently. Advertising shows the period that looks best. Bailey and López de Prado (2014) call this selection bias: results are reported without the number of trials.

What research shows: the factor zoo

“Now we have a zoo of new factors.”
Cochrane (2011)

This is how Cochrane (2011), in his presidential address to the American Finance Association, described the state of factor research. Harvey et al. (2016) drew the statistical consequence: with hundreds of papers and factors, a t-statistic of 2 is too low a hurdle. A new factor, they argue, should clear a t-statistic above 3.0; many claimed discoveries in financial research are probably false.

McLean and Pontiff (2016) examined 97 published variables that were supposed to predict the cross-section of stock returns. The returns of the corresponding portfolios were 26% lower out of the original sample and 58% lower after publication. The authors interpret the first part as an upper bound for data mining and the rest as a consequence of investors trading on the published patterns.

For individual strategies, Bailey and López de Prado (2014) developed the deflated Sharpe ratio: it corrects the measured Sharpe ratio for the number of trials and for non-normally distributed returns. Using combinatorially symmetric cross-validation (CSCV), Bailey et al. (2016) estimate the probability of backtest overfitting (PBO): how often does the variant that is best in the first part of the data fall below the median of all variants in the second part? The article probability of backtest overfitting shows, with a worked example, how the method goes through every split of the data into two halves of equal size.

Advanced: remedies

  1. Record the number of trials: every variant tested counts, including the discarded ones. Without this number, a result cannot be put into context.
  2. Raise the hurdle: compare the Sharpe ratio with the expected maximum from chance, or use the deflated Sharpe ratio; demand t-statistics above 3 rather than above 2.
  3. Test out of sample: choose parameters using only data up to a given point in time and then apply them unchanged, and do so on a rolling basis (walk-forward) across many points in time. A one-off hold-out period is better than nothing, but repeated peeking turns it into part of the sample itself.
  4. Check robustness: does the rule also work with neighbouring parameters, in other markets, in other decades and with trading costs? A single peak in a parameter grid is suspicious, a broad plateau less so.
  5. Demand an economic rationale: why should the premium persist? Risk, behaviour or constraints on other investors? Without an explanation, a pattern is more likely to be chance.
  6. Check the data: watch out for databases containing only surviving securities (survivorship bias), publication lags and revisions; check price series for jumps and frozen values.

For the Sharpe ratio itself, there is an additional point: its standard error is large (Lo 2002). Even without any trial and error, a Sharpe ratio of 0.5 after ten years is statistically hard to distinguish from zero. López de Prado (2018) describes further methods, such as purged cross-validation for time series, in which observations around the test period are removed from the training data.

Checklist for other people's backtests

  • How many variants were tested, and is this stated openly?
  • Does the period start and end at conspicuous points, for example shortly after a crash or at a peak?
  • Are trading costs, taxes and realistic execution (the next day at the earliest) taken into account?
  • Does the data set also include liquidated funds and stocks that dropped out of the index?
  • Is only data used that had been published at the respective point in time?
  • Does the result hold up in other markets, in other decades and with slightly changed parameters?
  • Is there a convincing reason why the premium should persist?

Limits of the remedies

  • Too strict is also wrong: if you dismiss every premium as chance, you overlook real, well-founded effects such as the equity market premium. Statistics can only provide probabilities.
  • The future is not just another data point: even an honestly tested effect can disappear when markets, rules or participants change.
  • Dependent trials: formulas like the one above assume independent trials. With similar variants, you have to estimate the effective number. That is a source of uncertainty in its own right.

How Portfolio Lab calculates

Portfolio Lab cannot prevent overfitting, but it can keep some biases small. On the Tactical page, each model calculates its signals using only prices up to the respective month-end; trades are executed at the closing price of that same month-end. That is a slightly optimistic assumption, because in practice you trade the next day at the earliest. The valuation model based on the Shiller CAPE works with a one-month lag. In Optimisation, the “Rolling” mode estimates the weights using only the data up to each point in time and thus shows an out-of-sample result. The Overfitting check tab in the Backtest results calculates the deflated Sharpe ratio and the probability of backtest overfitting across your portfolios; on the Tactical page, a separate tab tests a grid of parameters of the selected model with CSCV (methodology).

Note: the securities database contains securities that are tradable today. If you select funds from it and backtest them, you have survivorship bias, because closed funds are missing. The data checks flag anomalies in price series, such as jumps, frozen prices and gaps, as a warning, but do not correct them. How backtests are calculated in detail is described in the backtest methodology and the data checks.

Frequently asked questions

What is overfitting in a backtest?

A strategy is tuned to historical data until it looks very good there. It then mainly explains chance and works worse afterwards.

What is survivorship bias?

The bias that arises when only funds or stocks that still exist today are tested. Poor, closed funds are missing, and the past looks better than it was.

What is look-ahead bias?

When a backtest uses information that was not yet known at the respective point in time, such as earnings published later or revised economic data.

What is the deflated Sharpe ratio?

A correction of the Sharpe ratio for the number of variants tested and for non-normally distributed returns. It shows whether a result is more than luck among many trials.

How many years does a credible backtest need?

As many as possible, covering several crises and interest rate regimes. But what also matters is how many variants were tested and whether the result holds up out of sample.

Literature

  1. Bailey, David; Borwein, Jonathan; López de Prado, Marcos; Zhu, Qiji Jim (2016): The probability of backtest overfitting. The Journal of Computational Finance. doi:10.21314/jcf.2016.322
  2. Bailey, David H.; López de Prado, Marcos (2014): The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality. The Journal of Portfolio Management 40 (5), pp. 94–107. doi:10.3905/jpm.2014.40.5.094
  3. Brown, Stephen J.; Goetzmann, William; Ibbotson, Roger G.; Ross, Stephen A. (1992): Survivorship Bias in Performance Studies. Review of Financial Studies 5 (4), pp. 553–580. doi:10.1093/rfs/5.4.553
  4. Cochrane, John H. (2011): Presidential Address: Discount Rates. The Journal of Finance 66 (4), pp. 1047–1108. doi:10.1111/j.1540-6261.2011.01671.x
  5. Harvey, Campbell R.; Liu, Yan; Zhu, Heqing (2016): … and the Cross-Section of Expected Returns. Review of Financial Studies 29 (1), pp. 5–68. doi:10.1093/rfs/hhv059
  6. Lo, Andrew W. (2002): The Statistics of Sharpe Ratios. Financial Analysts Journal 58 (4), pp. 36–52. doi:10.2469/faj.v58.n4.2453
  7. López de Prado, Marcos (2018): Advances in Financial Machine Learning. Wiley.
  8. Malkiel, Burton G. (1995): Returns from Investing in Equity Mutual Funds 1971 to 1991. The Journal of Finance 50 (2), pp. 549–572. doi:10.1111/j.1540-6261.1995.tb04795.x
  9. McLean, R. David; Pontiff, Jeffrey (2016): Does Academic Research Destroy Stock Return Predictability?. The Journal of Finance 71 (1), pp. 5–32. doi:10.1111/jofi.12365

Full bibliography

This article explains a method; it is not investment or tax advice. Worked examples are simplified and rounded. All terms in the glossary.