Alpha or Luck? Backtest Overfitting and Look-Ahead Bias in 600 Simulated Stock Markets
In 300 simulated stock markets with no edge, a typical factor search still found one 99% of the time. The math of why, a script you can run, and the honest test that held false discoveries to 4%.

A factor that would have passed review
In 300 stock markets I simulated, nothing predicted returns. Value, quality, momentum and five other characteristics carried no premium at all. A typical research process, the kind that tries several dozen factor variants and keeps the best one, found an edge in 99% of those markets anyway, with an average reported Sharpe ratio of 1.18.
That is not a strawman. Campbell Harvey, Yan Liu and Heqing Zhu reviewed hundreds of published factors and concluded that a new one should clear a t-statistic of 3.0, not the usual 2.0, and that most claimed findings in financial economics are likely false. When Kewei Hou, Chen Xue and Lu Zhang replicated 452 published anomalies with value-weighted returns, 65% could not clear a t-value of 1.96, and 82% failed the stricter multiple-testing hurdle of 2.78.
Real data cannot tell you which of your own findings are luck, because you never learn the true answer. So I built markets where the answer is known. This piece walks through what they show: the arithmetic of keeping the best variant, a look-ahead leak that hides in a date column, the honest test that survived, and a short script that reproduces the first problem on your laptop. Everything here is simulated, and you can try it in the free Gedanken demo.
The arithmetic of keeping the best
Suppose a factor has no edge and you test it once at the usual bar, a one-sided t-statistic above 2. The chance it passes by luck is
where Φ is the standard normal distribution function. Now try N variants, independent of each other, and keep the best. The chance that at least one passes is
With N = 10 that is 20.6%. With N = 60 it is 74.9%. With N = 70 it is 80%. Nothing in the data changed; only the number of tries did. Real variants are correlated (a 6-month and a 12-month momentum share most of their information), so the true rate sits a little below the independent case, but the direction is the same: every extra variant you try and do not count raises the odds that your best result is noise.
Markets where the answer is known
Gedanken is a research engine I am building at Vector 1. It tests research methods, not just models, in simulated markets where the true answer is planted in advance, so every claimed edge can be scored as right or wrong. Its stock-factor pack builds each market like this:
- 200 stocks and 10 years of monthly returns, with about 32% annual volatility per stock.
- Two real characteristics, value and quality, that drift slowly from quarter to quarter.
- Each quarter ends, and each company reports one or two months later. That matches the SEC's 10-Q deadlines of 40 days after quarter end for large accelerated and accelerated filers and 45 days for everyone else.
- In 300 markets, value and quality carry a real premium: 0.08% to 0.20% a month per standard deviation of value, 0.06% to 0.16% for quality. In the other 300, both premia are zero.
- Momentum and five decoy characteristics carry no premium in any market.
- On each report date the stock moves by 3% per standard deviation of surprise in its fundamentals.
Each research method then runs on all 600 markets. In the 300 with no edge, any claimed edge is a false discovery. In the 300 with a planted edge, finding it is a real detection.
Two mistakes that compound
| Research approach | Claims an edge where none exists | Finds a real planted edge |
|---|---|---|
| Best of 76 factor variants, including quarter-end dates | 99% (reported Sharpe 1.18) | 100% |
| Best of 70 variants, clean dates | 64% (reported Sharpe 0.81) | 96% |
| One pre-registered test, quarter-end dates | 96% (Sharpe 1.06) | 100% |
| One pre-registered test, as-reported dates | 4.3% (Sharpe 0.01) | 90% |
Read the table from the bottom. One honest test claims a false edge in 4.3% of no-edge markets, close to its nominal 5%, and still finds 90% of the real ones. Each mistake on its own breaks it. Trying 70 variants on clean data pushes false discoveries to 64%. Keeping one hypothesis but stamping fundamentals at quarter end pushes them to 96%. Do both and you reach 99%.
The naive search's 100% detection rate in planted-edge markets looks like a strength. It is not. A method that says yes to almost everything will say yes to the real edges too.
The leak hiding in a date column
The quarter-end mistake deserves its own section because it is so easy to make. Most fundamental databases index a quarter's numbers by the period they describe. Join them to returns on that date and your model knows a company's results one to two months before the market did.
In these markets that early knowledge is exactly what moves prices: the report-day jump. A single, honest hypothesis tested on quarter-end dates claimed an edge in 96% of markets with no edge, with an average Sharpe of 1.06. Nothing about the hypothesis was wrong. The data join was.
The fix is a point-in-time join: attach each quarter's fundamentals on the date they were filed or announced, never earlier. In pandas, merge_asof on the report date with direction="backward" does this, as long as your data has a reliable report date. If it only has period-end dates, add a conservative lag, such as 45 days, and accept that you will be a little late rather than impossibly early.
The honest test
The disciplined test commits to one hypothesis before looking at results: value plus quality, as reported, positive sign. Because no choices are made on the data, the whole history counts as out of sample. It calls an edge real only if the probabilistic Sharpe ratio of the long-short returns clears 0.95. The probabilistic Sharpe ratio, from David Bailey and Marcos López de Prado, is the probability that the true Sharpe ratio exceeds a benchmark SR*, given the estimate and the shape of the returns:
Here SR̂ is the estimated per-period Sharpe ratio, n the number of periods, γ̂₃ the skewness and γ̂₄ the kurtosis of the returns. Fat tails and negative skew widen the denominator and make the test harder to pass, which is what you want in markets. When you have tried several variants, the deflated Sharpe ratio from the same authors raises SR* to account for the number of trials.
Reproduce the first mistake in 43 lines of Python
This script builds 200 markets with no edge, each with 60 persistent characteristics that predict nothing, and compares keeping the best of 60 with one test chosen in advance. It needs only NumPy and SciPy and runs in about eight seconds.
import numpy as np
from scipy.stats import kurtosis, norm, skew
rng = np.random.default_rng(7)
WORLDS, STOCKS, MONTHS, VARIANTS, RHO = 200, 200, 120, 60, 0.9
def long_short(signal, returns):
"""Top-minus-bottom quintile: the signal at month t earns the return at month t+1."""
s, r = signal[:-1], returns[1:]
k = s.shape[1] // 5
order = np.argsort(s, axis=1)
top = np.take_along_axis(r, order[:, -k:], axis=1).mean(axis=1)
bottom = np.take_along_axis(r, order[:, :k], axis=1).mean(axis=1)
return top - bottom
def t_stat(x):
return x.mean() / x.std(ddof=1) * np.sqrt(len(x))
def psr(x, benchmark=0.0):
"""Probabilistic Sharpe ratio (Bailey and Lopez de Prado): P(true Sharpe > benchmark)."""
sr = x.mean() / x.std(ddof=1)
denom = np.sqrt(1 - skew(x) * sr + (kurtosis(x, fisher=False) - 1) / 4 * sr**2)
return norm.cdf((sr - benchmark) * np.sqrt(len(x) - 1) / denom)
best_of_n_hits, one_test_hits = 0, 0
for _ in range(WORLDS):
# A market with no edge: returns ignore every characteristic.
returns = 0.08 * rng.standard_normal((MONTHS, STOCKS))
# Persistent characteristics, like value or quality scores, that predict nothing.
chars = np.empty((VARIANTS, MONTHS, STOCKS))
chars[:, 0] = rng.standard_normal((VARIANTS, STOCKS))
for t in range(1, MONTHS):
chars[:, t] = RHO * chars[:, t - 1] + np.sqrt(1 - RHO**2) * rng.standard_normal((VARIANTS, STOCKS))
ls = [long_short(chars[v], returns) for v in range(VARIANTS)]
best_of_n_hits += max(t_stat(x) for x in ls) > 2.0 # try them all, keep the best
one_test_hits += psr(ls[0]) > 0.95 # one hypothesis, chosen in advance
print(f"best of {VARIANTS}, t > 2: claims an edge in {best_of_n_hits / WORLDS:.0%} of no-edge markets")
print(f"one pre-registered test, PSR > 0.95: {one_test_hits / WORLDS:.0%}")
It prints:
best of 60, t > 2: claims an edge in 76% of no-edge markets
one pre-registered test, PSR > 0.95: 6%
The 76% matches the formula's 74.9% for 60 independent tries. The 6% for the single test is within sampling noise of its nominal 5% at 200 markets (the standard error is about 1.6 points). Change VARIANTS and watch the first number follow the formula.
A no-edge market has to be efficient
Building markets with a known answer has its own trap, and I hit it three times. If anything in a "no edge" market is predictable from public information but not yet in the price, the market quietly contains an edge, and every honest test will find it.
The first version of the stock pack moved prices on report day by the full change in fundamentals. But fundamentals drift back toward their average. With a quarterly persistence of ρ = 0.9, the expected next value given today's is ρ times today's, so the predictable part of the change is
A stock two standard deviations above average should expect a drop of 0.2 standard deviations at its next report, worth about −0.6% at 3% per standard deviation. That is public information, and in that first version it produced a reliable edge: the honest test averaged a Sharpe of −0.56 in markets that were supposed to have none. An efficient market moves only on the surprise, F_{q+1} − ρF_q. After that fix, the honest test averaged a Sharpe of 0.01 in no-edge markets, as it should.
The same check now runs on every market Gedanken builds: in no-edge markets, a pre-registered test should flag about 5% or less and average a Sharpe near zero. If yours does not, your simulator, not your strategy, is the thing with the edge.
When the research system improves itself
Gedanken also improves its own research methods. In practice that works through two roles. A proposer suggests one change at a time to the research method, and a fixed judge scores each change on 1,000 fresh no-edge markets and 400 with a planted edge. The judge accepts a change only if false discoveries stay at or under 5% and the gain in detection is significant after correcting for every change ever tried. The bar rises with the count: a one-sided z of 1.64 on the first try and 2.84 by the 22nd.
The first version of the judge allowed up to 6% false discoveries to leave room for sampling noise. The loop found that slack immediately: the one change it accepted lowered the evidence bar, and false discoveries landed at exactly 6.0%, right on the limit. That is Goodhart's law in a single round. I tightened the judge to a hard 5% and took control of the evidence bar away from the method. Under the stricter judge, the change that survived two separate runs was sizing positions by signal strength, which raised detection from 25% to 33% with 2.0% false discoveries. (Those loop results come from Gedanken's natural gas to fertilizer earnings pack, which runs on the same judge.)
The lesson carries to any system that tunes itself, including your own team's research process: whoever writes the scoring rules has to sit outside the thing being scored.
Where it breaks
These are simulated markets, and I chose their parameters. The 90% detection rate depends on premia of 0.08% to 0.20% a month and on 10 years of data; smaller premia or shorter histories would lower it. The markets have no transaction costs, short-sale limits or capacity constraints, all of which shrink real long-short returns. They have no regime changes either, though another Gedanken module checks whether real data has drifted outside the simulated range. And a method that survives known-answer markets is a better candidate, not a proven one: the next step is the same tests on real filings and prices.
What to do this quarter
Count every variant you try, including the ones you dropped early, and report that number next to any result. Date fundamentals by when they were filed or announced, and add a conservative lag where you cannot. Write the hypothesis down before you run the test, and raise the bar when you have tried more than once: a t-statistic of 3 is a reasonable start, a deflated Sharpe ratio is better. Before trusting a new research process with real money, run it on markets where you know the answer, and check that those markets are efficient when they are supposed to be.
You can try all of this in the Gedanken demo, compare the four approaches yourself, and see the self-improving loop's full record. More simulation methods are on the forecasting and simulation page, and the rest of my demos are on the demos page.
Sources
- Harvey, Liu and Zhu, … and the Cross-Section of Expected Returns, Review of Financial Studies, 2016
- Hou, Xue and Zhang, Replicating Anomalies, Review of Financial Studies, 2020
- Bailey and López de Prado, The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality, Journal of Portfolio Management, 2014
- U.S. Securities and Exchange Commission, Form 10-Q filing deadlines
- Vector 1, Gedanken demo and showcase repository; all results above are from Gedanken's simulated markets, Nov 19 to 20, 2026


