Run two hundred variations of a strategy on five years of daily data and keep the best one. Under the assumptions of this article, that best one will usually show an annualised Sharpe ratio around 1.3, a t-statistic above 3, and a Probabilistic Sharpe Ratio above 99.9%. None of those numbers is a bug. Each is a correct answer to a question nobody should be asking: how good does this strategy look if I pretend it was the only one I tried?
Backtest overfitting is not mainly about bad code or look-ahead bias, though both are common. It is a statistical problem: selection under noise. This article puts numbers on it. It covers the sampling error of the Sharpe ratio, the Probabilistic and Deflated Sharpe Ratios, the effective number of trials, and the Probability of Backtest Overfitting estimated by combinatorially symmetric cross-validation. Every number below comes from code that is shown and was run with fixed seeds.
1. The Sharpe Ratio Is an Estimate, and a Noisy One
1.1 Units first
Most errors in this area come from mixing units, so we fix them up front. Let be per-period excess returns (daily, in all examples here). The estimator is
a per-period Sharpe ratio, and is the number of periods. Every formula in this article uses those units. Annualisation happens only at the end, for display, by multiplying by with for daily data. This rule is valid only if returns are i.i.d. (see §1.3).
1.2 Standard error: Lo and Mertens
For i.i.d. normal returns, Lo (2002) gives the asymptotic distribution
The term comes from estimating as well as . For daily data it is negligible: a per-period SR of 0.06 contributes 0.0018. So in practice per period. In annual units that gives the rule of thumb most people never internalise:
A one-year backtest has an annualised-Sharpe standard error of about 1.0. Five years gives about 0.45, and ten years about 0.32. To reject at you need roughly years of data:
| True annual SR | Years for | Years for |
|---|---|---|
| 0.5 | 16 | 36 |
| 1.0 | 4 | 9 |
| 2.0 | 1 | 2.25 |
Mertens (2002) relaxes normality while keeping i.i.d. Let be the skewness and the raw kurtosis ( for a normal). Then
Setting recovers Lo's . Two consequences follow:
- Negative skew inflates the error, and the effect is proportional to . Short-volatility, carry and market-making P&L all have that profile.
- Fat tails inflate it quadratically in .
At daily frequency, with small per-period SRs, the correction is modest. At monthly frequency it is not. Take a monthly strategy with per-period (about 1.73 annualised), and . The numerator is , against under normality. The standard error is 55% larger than a naive calculation reports.
1.3 Annualisation under autocorrelation
The rule assumes serially uncorrelated returns. Lo (2002) gives the general aggregation factor for a -period Sharpe ratio:
where is the lag- autocorrelation of per-period returns. Positive autocorrelation, typical of smoothed or illiquid marks and of trend-following P&L at short horizons, makes , so the naive annualised Sharpe is overstated. Negative autocorrelation does the opposite. Strategies that mark to model or hold stale prices tend to have strongly positive , and their quoted annualised Sharpe ratios can be inflated by a large factor. If you report an annual figure, compute from the data rather than assuming .
2. The Probabilistic Sharpe Ratio
Bailey and López de Prado (2012) turn the Mertens distribution into a probability. Given a benchmark in per-period units, the Probabilistic Sharpe Ratio is
the estimated probability that the true Sharpe exceeds . It penalises short track records, negative skew and fat tails, which the raw Sharpe ignores. Its weakness is the one this article is about: PSR assumes the strategy was the only one tested. Feed it the winner of a search and it confidently certifies noise.
The building blocks, used throughout:
# sharpe_stats.py
import numpy as np
from scipy.stats import norm, skew, kurtosis
EULER_GAMMA = 0.5772156649015329
def sharpe(r):
"""Per-period Sharpe ratio (no annualisation, zero risk-free rate)."""
return r.mean() / r.std(ddof=1)
def sharpe_se(sr, T, g3=0.0, g4=3.0):
"""Std. error of the per-period Sharpe estimate (Mertens 2002).
g4 is raw kurtosis (3 for a normal); g3=0, g4=3 recovers Lo (2002)."""
return np.sqrt((1.0 - g3 * sr + (g4 - 1.0) / 4.0 * sr**2) / (T - 1))
def psr(r, sr_star=0.0):
"""Probabilistic Sharpe Ratio: P[true SR > sr_star], per-period units."""
sr = sharpe(r)
g3 = skew(r)
g4 = kurtosis(r, fisher=False) # raw kurtosis
z = (sr - sr_star) / sharpe_se(sr, len(r), g3, g4)
return norm.cdf(z)
def expected_max_sr(n_trials, sr_var):
"""E[max of n_trials zero-skill Sharpe estimates], per-period units."""
sd = np.sqrt(sr_var)
return sd * ((1 - EULER_GAMMA) * norm.ppf(1 - 1.0 / n_trials)
+ EULER_GAMMA * norm.ppf(1 - 1.0 / (n_trials * np.e)))
def dsr(r, n_trials, sr_var):
"""Deflated Sharpe Ratio: PSR against the expected maximum of noise."""
return psr(r, sr_star=expected_max_sr(n_trials, sr_var))
3. Selection: The Expected Maximum of Noise
3.1 The order statistic
Suppose you run independent trials, none with any skill. Each estimated Sharpe is approximately , with per period. The best of them is not zero. For large , extreme value theory approximates the expected maximum of i.i.d. standard normals as
with the Euler–Mascheroni constant. Scaling by gives the expected maximum Sharpe of zero-skill trials:
This is the bar that a selected strategy must clear. The bar grows with , roughly like : slowly, but without limit.
3.2 The Deflated Sharpe Ratio
Bailey and López de Prado (2014) define the Deflated Sharpe Ratio as the PSR evaluated against that bar:
It answers the question that matters: given that this strategy is the best of , and given its track-record length, skew and kurtosis, what is the probability that its true Sharpe is positive beyond what selection alone would produce? The usual decision rule is to require .
3.3 The experiment
We generate 200 strategies, each with five years (1,260 days) of i.i.d. normal daily returns, zero mean and 1% daily volatility. No strategy has any skill. We select the one with the best Sharpe, as a researcher scanning a parameter grid would.
import numpy as np
from sharpe_stats import sharpe, psr, dsr, expected_max_sr
rng = np.random.default_rng(42)
T, N = 1260, 200 # 5 years of daily returns, 200 trials
R = rng.normal(0.0, 0.01, size=(T, N)) # zero mean: no strategy has skill
srs = R.mean(0) / R.std(0, ddof=1) # per-period Sharpe of every trial
best = srs.argmax()
r_best = R[:, best]
print(f"best per-period SR : {srs[best]:.4f}")
print(f"best annualised SR : {srs[best] * np.sqrt(252):.2f}")
print(f"t-stat of best : {srs[best] * np.sqrt(T):.2f}")
print(f"PSR(SR*=0) : {psr(r_best):.4f}")
sr_var = srs.var(ddof=1) # cross-sectional variance of trial SRs
sr0 = expected_max_sr(N, sr_var)
print(f"E[max SR] (annual) : {sr0 * np.sqrt(252):.2f}")
print(f"DSR : {dsr(r_best, N, sr_var):.4f}")
Output:
best per-period SR : 0.0968
best annualised SR : 1.54
t-stat of best : 3.44
PSR(SR*=0) : 0.9997
E[max SR] (annual) : 1.30
DSR : 0.7022
Read the lines one at a time:
- Annualised Sharpe 1.54 over five years from pure noise. With a plausible story attached, many allocators would take that meeting.
- t-statistic 3.44. That clears the hurdle of Harvey, Liu and Zhu (2016), discussed in §5.
- PSR 0.9997. PSR does its job correctly and still says "almost certainly skill", because it was told this was a single trial.
- Expected maximum of 200 noise trials: 1.30 annualised. The winner beats the expected best of noise by only about 0.24, roughly half an annual standard error.
- DSR 0.70, below 0.95. Once the number of trials is counted, the evidence is not significant.
What happens after selection makes the same point. Continue all 200 strategies for two more years on fresh noise (an independent seed, 43, so the numbers above are unchanged). The in-sample winner then earns an annualised Sharpe of 0.20, adding about 6% to the 121% it made in-sample.
The same return series gives PSR = 0.9997 and DSR = 0.70. The only difference is whether you disclose that it was the best of 200. The number of trials is not a footnote: it is part of the test statistic.
Note on : the code uses the cross-sectional variance of the 200 estimated Sharpes, as Bailey and López de Prado recommend, rather than the theoretical . With independent trials the two agree closely: the version gives an annualised bar of 1.24 versus 1.30 here. The distinction becomes decisive once trials are correlated.
4. How Many Trials Did You Really Run?
4.1 Correlated trials are not independent trials
The formula for assumes independent draws. Real searches are nothing like that. Neighbouring lookback windows, thresholds that differ by one tick, and the same signal on overlapping universes all produce highly correlated P&L. Counting each variant as an independent trial overstates and makes DSR too harsh. Counting the whole grid as "one idea" makes it far too lenient.
A common heuristic is the average-correlation approximation
which interpolates between when every trial is the same () and when trials are independent. It is better than nothing, but in the experiment below it remains badly miscalibrated. The reason is that correlation affects the bar in two ways: it reduces the count, and it also shrinks the cross-sectional dispersion of the Sharpe estimates.
4.2 Experiment
We build 200 zero-skill strategies with pairwise return correlation . Each one loads on a common noise factor and on its own idiosyncratic noise. We repeat 500 times and compare the simulated expected maximum Sharpe with three candidate bars.
import numpy as np
from sharpe_stats import expected_max_sr
rng = np.random.default_rng(7)
T, N, rho, n_sims = 1260, 200, 0.6, 500
ann = np.sqrt(252)
maxes, bench_cs = [], []
for _ in range(n_sims):
common = rng.normal(0, 0.01, size=(T, 1))
idio = rng.normal(0, 0.01, size=(T, N))
R = np.sqrt(rho) * common + np.sqrt(1 - rho) * idio # pairwise corr = rho
srs = R.mean(0) / R.std(0, ddof=1)
maxes.append(srs.max())
# benchmark built from the cross-sectional dispersion of the trials
bench_cs.append(srs.mean() + expected_max_sr(N, srs.var(ddof=1)))
n_eff = rho + (1 - rho) * N # average-correlation approximation
print(f"simulated E[max SR] (annual) : {np.mean(maxes) * ann:.2f}")
print(f"formula, N={N}, iid variance 1/T : {expected_max_sr(N, 1/T) * ann:.2f}")
print(f"formula, N_eff={n_eff:.0f}, iid variance : {expected_max_sr(n_eff, 1/T) * ann:.2f}")
print(f"formula, N={N}, cross-sect. variance: {np.mean(bench_cs) * ann:.2f}")
simulated E[max SR] (annual) : 0.77
formula, N=200, iid variance 1/T : 1.24
formula, N_eff=81, iid variance : 1.10
formula, N=200, cross-sect. variance: 0.78
The true expected maximum is 0.77. Treating the trials as independent puts the bar at 1.24, far too high. Shrinking to helps only a little (1.10), because the bar depends on only through . The approach that works is to keep and use the observed cross-sectional variance of the trial Sharpes, centred on their cross-sectional mean. It gives 0.78, almost exactly right. Under the factor structure the trials share a common component, and only the idiosyncratic part, with variance , generates spread for selection to exploit. The empirical dispersion measures that spread directly.
The practical rules:
- Log every trial's return series, not just the winner's. Without the cross-section you cannot estimate .
- If trials fall into families (different signals, each with a parameter grid), cluster them, for example hierarchically on the correlation matrix. Then treat the number of clusters as and the dispersion of cluster-representative Sharpes as . This is the approach López de Prado advocates in later work, and it is more robust than any single scalar .
5. Why a t > 3 Hurdle Is Not Enough
Harvey, Liu and Zhu (2016) surveyed hundreds of published cross-sectional return factors. Using multiple-testing adjustments (Bonferroni, Holm, Benjamini–Hochberg–Yekutieli), they argued that a newly proposed factor should clear rather than the conventional 2.0. The point is sound, and the hurdle is a large improvement over 1.96. But that threshold was calibrated to the number of hypotheses tested by the profession as they estimated it, not to the number your own research process tested.
The experiment in §3.3 produced from 200 zero-skill trials. A private grid search over a few hundred configurations is a routine afternoon. A fixed threshold cannot replace accounting for your own . Since , the DSR is effectively a hurdle that scales with , and the shape of the return distribution together.
6. Probability of Backtest Overfitting (CSCV)
DSR asks whether the selected strategy's performance exceeds what selection would produce. A complementary question is whether the selection procedure itself tends to pick strategies that underperform out of sample. Bailey, Borwein, López de Prado and Zhu answer it with combinatorially symmetric cross-validation (CSCV) and the statistic they call the Probability of Backtest Overfitting (PBO).
6.1 Procedure
Stack the per-period returns of all trials into a matrix and split its rows into contiguous blocks of equal size ( even). For every one of the ways to choose half the blocks:
- The chosen blocks form the in-sample set , and the complementary blocks form the out-of-sample set . Both have the same length, which is what "symmetric" refers to.
- Compute every trial's Sharpe on and on .
- Let be the trial with the best in-sample Sharpe.
- Find its relative rank out of sample, , and its logit .
Then
the fraction of splits in which the in-sample winner ranks at or below the median out of sample. A selection procedure with no real information should land near 0.5. Values well below 0.5 mean the procedure picks trials that keep working.
6.2 Implementation
A naive implementation recomputes means and variances for all splits from the raw matrix. Precomputing per-block sums and sums of squares makes each split an operation:
# pbo.py
import numpy as np
from itertools import combinations
def pbo_cscv(R, S=16):
"""Probability of Backtest Overfitting via CSCV.
R: (T, N) matrix of per-period returns, one column per trial."""
T, N = R.shape
blocks = np.array_split(np.arange(T), S)
# sufficient statistics per block -> Sharpe of any union of blocks is cheap
n = np.array([len(b) for b in blocks], dtype=float) # (S,)
s1 = np.stack([R[b].sum(0) for b in blocks]) # (S, N)
s2 = np.stack([(R[b] ** 2).sum(0) for b in blocks]) # (S, N)
def sr(idx):
k = n[idx].sum()
m = s1[idx].sum(0) / k
v = (s2[idx].sum(0) - k * m**2) / (k - 1)
return m / np.sqrt(v)
logits, is_best, oos_best = [], [], []
for combo in combinations(range(S), S // 2):
is_idx = np.array(combo)
oos_idx = np.setdiff1d(np.arange(S), is_idx)
sr_is, sr_oos = sr(is_idx), sr(oos_idx)
star = sr_is.argmax() # the trial you would pick
rank = (sr_oos < sr_oos[star]).sum() + 1 # 1..N, N = best OOS
w = rank / (N + 1) # relative rank in (0,1)
logits.append(np.log(w / (1 - w)))
is_best.append(sr_is[star]); oos_best.append(sr_oos[star])
logits = np.array(logits)
return {
"pbo": float((logits <= 0).mean()),
"logits": logits,
"sr_is": np.array(is_best),
"sr_oos": np.array(oos_best),
}
6.3 Noise versus edge, one realisation
We apply it first to the exact 200 noise strategies from §3.3. Then we take the same matrix and add genuine drift to one column, at true annualised Sharpe ratios of 0.5, 1.0 and 2.0:
import numpy as np
from pbo import pbo_cscv
ann = np.sqrt(252)
rng = np.random.default_rng(42)
T, N = 1260, 200
noise = rng.normal(0.0, 0.01, size=(T, N))
res = pbo_cscv(noise, S=16)
print(f"noise only : PBO = {res['pbo']:.3f}, "
f"median IS SR = {np.median(res['sr_is']) * ann:.2f}, "
f"median OOS SR = {np.median(res['sr_oos']) * ann:.2f}")
for true_sr in (0.5, 1.0, 2.0): # annualised Sharpe of one real strategy
R = noise.copy()
R[:, 0] += true_sr / ann * 0.01 # shift the mean of column 0
res = pbo_cscv(R, S=16)
print(f"edge SR={true_sr:.1f}: PBO = {res['pbo']:.3f}, "
f"median OOS SR of pick = {np.median(res['sr_oos']) * ann:.2f}")
noise only : PBO = 0.300, median IS SR = 1.79, median OOS SR = 0.78
edge SR=0.5: PBO = 0.323, median OOS SR of pick = 0.73
edge SR=1.0: PBO = 0.243, median OOS SR of pick = 0.68
edge SR=2.0: PBO = 0.059, median OOS SR of pick = 1.99
Two results deserve attention.
First, the noise-only PBO is 0.30, not 0.5, and the median out-of-sample Sharpe of the pick is a positive 0.78. This is not a flaw in the code. It shows what CSCV can and cannot see. Every split re-partitions the same realised path. In this realisation one column happens to have a full-sample Sharpe of 1.54 (the §3.3 winner), so it tends to win in-sample on many splits and stay above median out of sample. CSCV measures how stable the selection is within the data you have. It cannot tell a lucky path from a skilful one. That is DSR's job, and it is why the two statistics complement each other rather than substitute for one another.
Second, edge is detectable only when it is large relative to sampling error. A true annual Sharpe of 0.5 among 199 noise trials over five years is invisible: the PBO of 0.32 is indistinguishable from the noise-only case, because the real strategy rarely wins in-sample. Its edge is about one annual standard error, while the noise maximum is around 2.8 standard errors. At a true Sharpe of 2.0, the real strategy wins almost every split, PBO falls to 0.06, and the out-of-sample Sharpe of the pick (1.99) matches its true value.
6.4 PBO has its own sampling distribution
Because a single realisation can mislead, we repeat the experiment over 100 seeds. We use to keep run time short; there are 252 splits per run.
import numpy as np
from pbo import pbo_cscv
ann = np.sqrt(252)
T, N = 1260, 200
pbo_noise, pbo_edge = [], []
for seed in range(100):
rng = np.random.default_rng(seed)
noise = rng.normal(0.0, 0.01, size=(T, N))
pbo_noise.append(pbo_cscv(noise, S=10)["pbo"])
R = noise.copy(); R[:, 0] += 2.0 / ann * 0.01
pbo_edge.append(pbo_cscv(R, S=10)["pbo"])
pbo_noise, pbo_edge = np.array(pbo_noise), np.array(pbo_edge)
print(f"noise : mean PBO = {pbo_noise.mean():.2f}, "
f"5-95% = [{np.quantile(pbo_noise,.05):.2f}, {np.quantile(pbo_noise,.95):.2f}]")
print(f"edge : mean PBO = {pbo_edge.mean():.2f}, "
f"5-95% = [{np.quantile(pbo_edge,.05):.2f}, {np.quantile(pbo_edge,.95):.2f}]")
noise : mean PBO = 0.53, 5-95% = [0.27, 0.76]
edge : mean PBO = 0.17, 5-95% = [0.01, 0.39]
On average, noise gives PBO ≈ 0.53, as theory predicts, and a genuine Sharpe-2 strategy gives 0.17. But the 90% ranges overlap. A noise-only search lands at 0.27 or lower one time in twenty, and a real edge lands at 0.39 or higher one time in twenty. A single PBO estimate is evidence, not a verdict.
PBO measures how reliable your selection procedure is on the data you have. DSR measures whether the selected result beats what selection would produce. Overfitting can hide from either one. It struggles to hide from both.
6.5 Choosing S and reading the output
- trades resolution against block length. Larger gives more splits, but each block is shorter, and blocks must be long enough that the Sharpe in each half means something and that serial dependence does not leak across block boundaries. With daily data, between 10 and 16 over five or more years is a reasonable range.
- Look beyond the headline PBO. The pairs for the selected trial give the performance degradation slope: regress OOS on IS. Strongly negative slopes are the signature of a search that rewards in-sample noise. The share of splits with is the probability of an out-of-sample loss.
- CSCV inherits your data's regime structure. With contiguous blocks, a single regime shift can dominate. That is a feature if you want to know whether the selection survives regimes, and a confound if you do not.
7. Putting It Together
| Question | Tool | Needs |
|---|---|---|
| Is this single, pre-specified strategy's Sharpe distinguishable from zero? | PSR(), Mertens SE | Return series, , skew, kurtosis |
| Is the selected strategy better than the best of noise? | DSR | Above, plus and the cross-section of trial Sharpes |
| Does my selection procedure pick trials that persist? | PBO via CSCV | Full matrix of trial returns |
| Is my annualised figure even comparable? | Lo's | Autocorrelations |
All four tools need one thing standard backtest reports omit: the record of everything you tried.
8. Research Hygiene Checklist
- Log every trial. Store the configuration, the code hash, and the full per-period return series for every backtest you run, including the ones you discard. This is what makes DSR and PBO computable afterwards.
- Report . Always disclose the number of trials, and the number of clusters if you clustered. A Sharpe ratio without cannot be interpreted.
- Pre-register before you look. Write down the hypothesis, universe, sample period, cost model, parameter ranges and the selection metric before you run anything. Every later change is a new trial and gets counted.
- Separate the hold-out physically. Reserve a final out-of-sample period you have never touched, ideally kept in a separate store you cannot query casually. Use it once. If you go back after looking, it is no longer a hold-out.
- Report Sharpe with its standard error. Use Mertens rather than Lo whenever skew or kurtosis are material, and compute annualisation with when returns are autocorrelated.
- Use DSR > 0.95 as a gate, with taken from the observed cross-section of trial Sharpes, not from .
- Run CSCV on the full trial matrix and report the PBO, the degradation slope and the probability of an out-of-sample loss. Treat one PBO as a noisy estimate.
- Prefer fewer, economically motivated trials. The bar rises with , but every trial you never run is free. A hypothesis grounded in a mechanism (who is forced to trade, and why) shrinks before the search even starts.
- Budget for decay. Even a strategy that passes all of the above should be sized for an out-of-sample Sharpe meaningfully below its backtest. Selection bias never goes to zero; it only becomes measurable.
References
- Bailey, D. H., Borwein, J. M., López de Prado, M., & Zhu, Q. J. "The Probability of Backtest Overfitting." Journal of Computational Finance.
- Bailey, D. H., & López de Prado, M. (2012). "The Sharpe Ratio Efficient Frontier." Journal of Risk, 15(2).
- Bailey, D. H., & López de Prado, M. (2014). "The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality." Journal of Portfolio Management, 40(5).
- Harvey, C. R., Liu, Y., & Zhu, H. (2016). "…and the Cross-Section of Expected Returns." Review of Financial Studies, 29(1).
- Lo, A. W. (2002). "The Statistics of Sharpe Ratios." Financial Analysts Journal, 58(4).
- Mertens, E. (2002). "Comments on Variance of the IID Estimator in Lo (2002)." Working paper, University of Basel.
Research and education, not investment advice.