QTQuant Terminal
A2-05A2·intermediate·~19 min

Hypothesis testing — is this strategy real or luck?

statisticshypothesis-testingp-valuemultiple-testing

▸ Pretest — guess, even if you don't know

You backtest 1,000 random strategies. Some show a positive Sharpe with p-value < 0.05. About how many do you expect to be 'significant' by pure chance?

The setup

Hypothesis testing is a framework for asking: could this observation be explained by random chance alone?

The structure:

For a strategy with mean return rˉ\bar{r} and standard error SE(rˉ)\text{SE}(\bar{r}):

t=rˉSE(rˉ)=rˉσ/Nt = \frac{\bar{r}}{\text{SE}(\bar{r})} = \frac{\bar{r}}{\sigma / \sqrt{N}}

Under H0H_0 (true mean is zero), tt is approximately t-distributed with N1N-1 degrees of freedom. For large NN, it's approximately standard normal.

So t>1.96|t| > 1.96 corresponds (roughly) to p < 0.05.

Translating to Sharpe

Notice the t-statistic for "mean return ≠ 0" is closely related to Sharpe:

t=rˉσ/N=Sharpe^N/Tannualt = \frac{\bar{r}}{\sigma / \sqrt{N}} = \widehat{\text{Sharpe}} \cdot \sqrt{N} / \sqrt{T_\text{annual}}

where Tannual=252T_\text{annual} = 252 for daily data. The point is: a higher Sharpe and a longer backtest both increase t. A Sharpe of 1 over 5 years has t52.24t \approx \sqrt{5} \approx 2.24, just barely "significant." Over 10 years, t3.16t \approx 3.16 — clearly significant.

This is why long backtests are powerful — not because the Sharpe is better, but because the statistical evidence is stronger for the same Sharpe.

The p-value, honestly

A p-value is not:

A p-value is:

This distinction matters. A study can have p = 0.001 and tiny effect size (millions of observations, trivially small mean). Or p = 0.10 and a huge effect (few observations, large mean). The p-value is one number among many.

The multiple-testing problem

If you test one strategy honestly and get p = 0.03, you have moderate evidence.

If you tested 100 strategies and report the best one with p = 0.03 — you have no evidence. By chance alone, 5 out of 100 strategies would show p < 0.05 even if all of them had zero true edge.

This is the most common way retail quants fool themselves. Tuning parameters, trying different indicators, varying lookback windows — every variation is a new test. The published backtest you settle on is the survivor of many quiet failures, and its statistics are dramatically inflated.

Corrections

Several adjustments exist:

Harvey-Liu-Zhu (2016) "factor zoo"

A landmark paper: surveyed hundreds of "factors" published in finance journals claiming to explain stock returns. Argued that with proper multiple-testing corrections, the published t-statistic threshold for a "real" factor should be ~3.0, not the standard 2.0. Many published factors don't survive this bar.

The implication for retail: most "edges" you find online don't survive honest multiple-testing scrutiny. Be very skeptical.

A practical recipe for evaluating your own strategies

  1. State your hypothesis in writing before you backtest. "Mean reversion in S&P 500 stocks over 1-day horizons makes money." Specific.
  2. Backtest once, with parameters chosen a priori from theory or prior literature (not optimized on the same data).
  3. Report the actual t-statistic and p-value of mean returns.
  4. Multiply expected effect size by realistic transaction costs (5–20 bps per round trip for retail). Many "edges" vanish under realistic costs.
  5. If you iterate, keep a log of every variant tested. Apply a multiple-testing correction at the end.
  6. Out-of-sample: hold back the last 20-30% of data and only test the final strategy there once.

This is the discipline that separates serious quants from people who fool themselves.

Try it

Compute the t-statistic for "is this strategy's mean return different from zero?":

▮ EXERCISE · a2-05-ex1

Implement t_stat(returns) = mean / (std / sqrt(N)), where std is the sample standard deviation with ddof=1 and N is the number of observations. This is the test statistic for the null hypothesis that the true mean return is zero.

⧉ Review card
What is the p-value, precisely?
The probability of observing data at least as extreme as what you saw, assuming the null hypothesis is true. It is NOT the probability the null is true.
⧉ Review card
If you test 100 random strategies, how many do you expect to be 'significant' at p < 0.05?
About 5 (5% of 100). Each test is independently 5% likely to hit by chance. This is the multiple-testing problem.
⧉ Review card
What's the relationship between t-statistic and Sharpe ratio?
For a daily return series of N days, t ≈ Sharpe × √(N/252). A Sharpe of 1 over 5 years gives t ≈ 2.24; over 10 years t ≈ 3.16.
⧉ Review card
What is the Deflated Sharpe Ratio?
(López de Prado 2018) A correction to Sharpe that accounts for the number of trials you ran, the variance of Sharpe across trials, and higher moments. Should be used instead of raw Sharpe when reporting backtest results that survived parameter search.
⧉ Review card
What was Harvey-Liu-Zhu (2016)'s key conclusion?
With proper multiple-testing corrections, the t-statistic threshold for declaring a factor 'real' should be ~3.0, not the standard 2.0. Many published factors are not robust.

Predict before the next lesson

Tomorrow we shift back to finance with alpha (excess return vs. a benchmark). Predict:

◈ Calibration check

Could you state the difference between a p-value and the probability that the null hypothesis is true?

1 = guessing · 5 = could teach it

⏻ End of lesson

Mark it read to book its 5 review cards into your deck.

Sources & further reading