Quant 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 one question: could this observation be explained by random chance alone?

The structure:

The test statistic for a strategy's mean return uses two new symbols. A bar over a symbol, as in rˉ\bar{r} (read "r bar"), means "the average of r." And SE(rˉ)\text{SE}(\bar{r}) — the standard error of the mean — is the typical distance between your sample average and the true mean:

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

In words: the t-statistic is the average return divided by its standard error. Equivalently: divide the average return by the standard deviation over the square root of the sample size. It answers: "how many standard errors is the average away from zero?"

Concrete feel: if your average daily return is 2 standard errors above zero, t = 2. That's hard to get by luck alone.

Under H0H_0 (true mean is zero), tt approximately follows the t-distribution — a bell curve slightly wider than the normal, with "N1N-1 degrees of freedom" (a parameter that grows with sample size and controls how wide). For large NN, it's approximately the standard normal bell curve you've already met.

Consequence: t>1.96|t| > 1.96 — read "the absolute value of t is bigger than 1.96," meaning t is beyond ±1.96 in either direction — corresponds (roughly) to p < 0.05. That's where the famous "2 standard errors" rule comes from.

Translating to Sharpe

Notice the t-statistic for "mean return ≠ 0" (the ≠ symbol reads "is not equal to") is closely related to the Sharpe ratio from A2-04:

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

In words: the t-statistic equals the estimated Sharpe ratio times the square root of the number of observations, divided by the square root of the periods per year. (The hat on Sharpe^\widehat{\text{Sharpe}} again marks an estimate from data; TannualT_\text{annual}, read "T sub annual," is 252 for daily data.)

The point: a higher Sharpe and a longer backtest both increase t. Simplified for annual units, t ≈ Sharpe × √years. A Sharpe of 1 over 5 years has t52.24t \approx \sqrt{5} \approx 2.24 — just barely past the 1.96 bar, so 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. Effect size — how big the thing you measured actually is — is separate from how statistically detectable it is. A study can have p = 0.001 and a tiny effect size: with millions of observations, even a trivially small mean return becomes "significant." Or p = 0.10 with 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. It surveyed hundreds of "factors" — measurable characteristics, like company size or recent momentum, claimed to explain stock returns — published in finance journals. The argument: academia as a whole has run thousands of tests, so the field has a giant multiple-testing problem. With proper corrections, the t-statistic threshold for calling a factor "real" 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 — meaning in advance, from theory or prior literature — not optimized on the same data you're testing.
  3. Report the actual t-statistic and p-value of mean returns.
  4. Check the edge against realistic transaction costs — for retail, 5–20 bps per round trip (a bps, or basis point, is 0.01%; a round trip is one buy plus one sell). 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 test — evaluation on data your development process never touched: hold back the last 20-30% of data and test the final strategy there exactly 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