How strategies are evaluated
This page describes the checks behind the statistical reference on an equity strategy page and the Stat % column in the
strategy table.
The code is engine/src/statistical_validation.py.
It reads each strategy-[id].json backtest and, when present, the
optimization-[id].json parameter grid for ^GSPC.
Two scores, one verdict
A backtest can look good because the average daily return is a bit above zero, and still be a poor trading rule: the edge can sit in one regime, the drawdown can be too deep, or the result can vanish once an extra cost is charged. The evaluation therefore reports two scores.
- Statistical validity. Is the result distinguishable from noise, does it hold on later data, and is the chosen parameter a single spike in the grid?
- Economic performance. Does the path have a positive trade edge, a bounded drawdown, enough time in the market, and a gain that is not confined to calm markets?
Stat % on the strategy table is still one number: passes divided by evaluated gates, across both groups. Skipped gates are left out of that fraction. The strategy page also shows each group on its own.
The verdict uses both rates and four must-pass gates: hold-out, trade edge, drawdown, and cost stress. All four must be evaluated and passed, and each group must pass at least 60% of its gates, with no more than three failures overall, before the verdict is strong. If either group is under 45% the verdict is not strong. Two or more must-pass failures, or both groups under about a third, produce weak. Everything else is moderate or mixed.
Per-index tests run on every symbol in the backtest file. The parameter grid, the deflated Sharpe, the block-bootstrap of the mean, and the economic gates use the S&P 500 run (^GSPC). When that symbol is missing, the first available run is the reference.
Stage 1 — Return significance
Daily strategy returns, taken from the equity curve, are tested against a mean of zero. The covariance is Newey–West (HAC) with 5 lags, so a few days of clustered gains do not shrink the standard error as if the days were independent. If statsmodels is not installed, the test falls back to a one-sided Student t-test.
A pass also requires a large enough sample: more than 100 trading-day observations, and at least 2 closed trades per year. The trade rate uses the stored trades_per_year when the backtest wrote it, otherwise total trades divided by the span from start date to end date. The p-value cutoff is 0.05, one-sided, for a positive mean.
This stage does not say the rule beats the index. It says the average daily return is unlikely to be zero given the sample that was tested.
Stage 2 — Hold-out
The return series is split in calendar order, 70% in sample and 30% out of sample. Each piece needs enough observations to compute an annualized Sharpe: mean excess return divided by its standard deviation, times the square root of 252. The risk-free rate inside this Sharpe is zero, so it is a return-to-volatility ratio rather than a rate in excess of T-bills.
The gate passes only when out-of-sample Sharpe is strictly positive. If in-sample Sharpe is also positive, out-of-sample Sharpe must be at least half of it. A ratio of two negative Sharpes does not pass, even when the later window is “less bad.” If in-sample Sharpe is negative and out-of-sample Sharpe is positive, the ratio rule is skipped and the positive out-of-sample result is enough.
One split is not a full walk-forward. It is a single later window on the same fixed rules. The parameters were not re-estimated inside this function; the equity curve is the one the backtest already stored.
Stage 3 — Walk-forward folds
The same return series is cut into four contiguous folds. Each fold gets its own annualized Sharpe. The gate passes when the median of those Sharpes is positive and at least half of the folds are positive. A strategy that earns its whole sample in one window fails, even if the full-sample Sharpe is high.
Folds are slices of the stored path. They are not a re-optimization. A series shorter than 80 observations skips this stage.
Stage 4 — Probabilistic Sharpe
The probabilistic Sharpe ratio (Bailey and López de Prado) is the probability that the true Sharpe is above a hurdle, after sample length, skewness, and kurtosis. The hurdle here is zero. The Sharpe inside the formula is the per-period ratio of mean to standard deviation, not the annualized number.
Let SR be that per-period Sharpe, n the number of returns, γ₃ the skewness, and γ₄ the raw fourth moment (about 3 for a normal sample). Then
PSR = Φ( (SR) · √(n − 1) / √(1 − γ₃·SR + (γ₄ − 1)/4 · SR²) )
Φ is the standard normal cdf. The gate passes when PSR is at least 0.95. The panel also shows the minimum track-record length: how many years of this same Sharpe, skew, and kurtosis would be required to reach that 0.95 confidence. A short sample with a modest Sharpe fails even when the point estimate looks fine.
Stage 5 — Drawdown path
Shuffling the daily returns and recomputing Sharpe does not test anything. Mean and standard deviation are unchanged by order, so every shuffle matches the original Sharpe. Max drawdown does depend on order. This stage block-bootstraps the return series (blocks of 21 days when the sample is long enough, 160 paths) and rebuilds the compounded equity path of each resample.
Badness is the percentage of bootstrap paths whose max drawdown is at least as deep as the observed path. The gate passes when that percentile is 90 or lower: the live path is not in the worst tenth of reorderings that keep local dependence. A pass means the loss sequence is not an extreme cluster relative to the strategy’s own returns. It is not a promise that the drawdown is small. The size of the drawdown is the economic gate below.
Stage 6 — Deflated Sharpe
Trying many strategies and many parameter values inflates the best Sharpe. The deflated Sharpe in engine/src/overfitting_gates.py haircuts the annualized Sharpe for the number of trials, the length of the sample, and the skewness and kurtosis stored on the run. The gate passes when that haircut Sharpe is still above 0.30.
The trial count k is the size of this strategy’s parameter grid multiplied by the number of strategies in the library, when that count is supplied. That is deliberate: the published library is itself a search. Using only this strategy’s grid would treat the other rules as if they had never been tried. The number is a haircut, not the probabilistic Sharpe from stage 4. Stage 4 ignores the search. Stage 6 exists to put the search back in.
Stage 7 — Block bootstrap of the mean
An overlapping block bootstrap (block length 21 on long samples, 400 draws) builds a 95% confidence interval for the mean daily return of the reference equity curve. The gate passes when the observed mean is positive and the lower end of the interval is still above zero. Blocks keep short-run dependence that an ordinary bootstrap would break.
Stage 8 — Parameter plateau
The optimizer writes one Sharpe per parameter combination on ^GSPC. A real edge usually shows up on a neighborhood of settings, not on a single cell. Plateau fraction is the share of grid points whose Sharpe is at least 80% of the best Sharpe (or within 0.05 of the best when the best is not positive).
The gate passes when that share is at least 20%. If the best and the median are both positive, the best must also be no more than twice the median. There is one such gate. An older pair of stages used the same best-to-median ratio twice, with two cutoffs, and counted it as two passes.
Stage 9 — CSCV is not scored
Combinatorially symmetric cross-validation estimates the probability of backtest overfitting from a matrix whose columns are the return series of each trial. The optimization file stores summary statistics, not those series. Building fake columns by rescaling one equity curve until each column has a target Sharpe makes every trial move together, so in-sample and out-of-sample ranks agree for mechanical reasons and the probability is pushed toward zero.
The stage is listed and skipped. It does not enter Stat %. A real CSCV can be added when each grid point keeps its own returns. The implementation of the matrix test remains in engine/src/overfitting_gates.py for studies that do have that matrix.
Stage 10 — Cost stress
Index backtests already charge 0.10% commission per fill (commission=0.001 in the engine). This gate adds a further 10 basis points per side, spread evenly across bars in proportion to trades per year:
cost per bar = (trades per year) × (2 × 10 bps) / 252
That amount is subtracted from every daily return and the Sharpe is recomputed. The gate passes when the haircut Sharpe is still positive. It is a turnover stress, not a market-impact model. A rule that trades constantly can fail here while its published Sharpe, which already includes the original commission, still looks acceptable. This gate is one of the four must-pass items.
Stage 11 — Trade edge
Daily returns mix days in a position with days in cash. A strategy that is flat most of the time can show a small positive daily mean that has little to do with the trades. This gate uses the closed-trade statistics already stored on the run.
It passes when expectancy is above zero and the profit factor is above 1, with at least five closed trades. Expectancy is the average result of a trade: win rate times average win, plus loss rate times average loss. Profit factor is gross profit divided by gross loss. If every trade won, the stored profit factor is written as 0 in place of infinity; that case still passes when expectancy is positive and there are no losing trades.
Stage 12 — Drawdown and downside
Max drawdown on the run is the deepest peak-to-trough loss, as a negative percent. The gate passes when that loss is no worse than −40% and at least one downside ratio clears its floor: Calmar (CAGR divided by the absolute max drawdown) at least 0.30, or Sortino at least 0.50. Sortino uses downside deviation rather than total volatility, so a strategy with large up-moves is not punished the way Sharpe punishes it.
The ulcer index is shown beside the decision but is not part of the cutoff. Failing this gate blocks a strong verdict even when the statistical tests pass.
Stage 13 — Exposure
Exposure-adjusted return is total return divided by the fraction of bars the strategy was invested. The gate passes when that figure is positive and time in market is at least 5%. The floor is low on purpose: a selective rule should not fail for sitting in cash. It should fail if the only “return” is a rounding error on a book that was barely ever open, or if the invested book itself lost money.
Stage 14 — Regime split
The backtest already stores the strategy’s compounded return in four buckets of the reference index: bull, bear, high volatility, and low volatility. The gate passes when the bear bucket or the high-vol bucket is positive, so the result is not only a long bet on a quiet uptrend. If those stress buckets were measured and both lost money, while the only gains are bull and low-vol, the gate fails. If fewer than two buckets are present, the stage is skipped.
These buckets are not the regime dropdown on the strategy table. The table regime view is built later from monthly index states and is documented on the strategy table page.
Stage 15 — Positive years
Monthly returns on the run are compounded inside each calendar year. The gate passes when at least half of those years are positive and at least three years exist. If the monthly series is missing, the daily returns are grouped into non-overlapping blocks of 252 bars and treated the same way. One exceptional year cannot carry the stage by itself once three years are present; it also cannot pass the stage alone, because three years are required before the test runs.
Stage 16 — Benchmark
The strategy Sharpe must be at least 0.50. When the run has both an alpha and an information ratio against its benchmark, alpha must be positive and the information ratio must be at least 0.20. A Sharpe of 0.20, or a tiny positive alpha with no hurdle on the ratio, used to be enough. That bar passed long-only rules that mostly held market beta.
Alpha and the information ratio are whatever the backtest stored. This stage does not re-estimate the regression. Beta is displayed and is not a pass/fail input.
Cross-market counts
The strategy page counts how many symbols pass the t-test, the hold-out, the walk-forward, and the benchmark gate. Those counts are context. They are not averaged into the verdict. A rule that works on one index and fails on the rest can still show a moderate reference-symbol score; the cross-market line is how you see that.
What a pass does not mean
- The tests use one stored backtest. They do not place orders, and they do not know the capacity of the book.
- The cost stress is a flat extra commission. It is not square-root market impact. Studies that model impact live under the momentum overfitting project, not in this gate.
- Walk-forward folds and the hold-out do not re-fit parameters. They only ask whether the path that was already produced stayed positive later.
- Deflated Sharpe depends on the trial count it is given. A smaller k would make the same backtest look better.
- None of the gates is a forecast. A strong verdict means the historical path cleared these hurdles. It is not a recommendation to trade the rule.
Regenerating the files
python scripts/generate_statistical_validation.py writes
data/statistical-validation/validation-[id].json for each equity strategy that has a backtest or an optimization file.
The site reads the copy under public/data/statistical-validation/.
Stat % in strategies-data.json is filled when that summary is rebuilt from these files. Until both steps are run, the strategy page and the table still show the previous scores.