Bentrix Docs
HomePricingDashboard

Statistics against chance

What the deflated Sharpe ratio, the probability of backtest overfitting, the minimum backtest length, the haircut and the family tests each say — in plain words, then exactly — and how Bentrix computes them from your own runs.

The question they all ask

Is this result better than what luck would produce, given how many things were tried?

A batch's line answers it for the best cell of a batch: Deflated Sharpe 0.71 · PBO 0.34 · 26 trials. The family tests answer it for a set of candidates against a benchmark. Each figure here is computed by Bentrix's own code from your runs' own trades. The answer gives each figure with its definition, and labels the conventions as conventions.

01The observation: a day

A cell's return a day is the money its deals booked that day — profit, swap and commission — over its opening balance, and zero on a day it booked nothing. Daily figures are turned into yearly ones with the market's own trading days a year: the days the recording holds candles for, over the span's years. A currency pair trades about 260 days, a crypto market 365. The common 252 is used only when nothing was measured, and then the answer says so.

02The Sharpe ratio, and its probability

The Sharpe ratio here is the mean daily return over its standard deviation, with no risk-free rate. It is a ratio of reward to wobble, not a return.

The probabilistic Sharpe ratio (PSR) is the probability that the strategy's true Sharpe ratio is above a benchmark, given how many days were observed and how lopsided (skew) and fat-tailed (kurtosis) the returns were. Few days, a negative skew or fat tails all lower it. In Bailey and López de Prado's form:

PSR = Φ( (SR − SR\*) · √(n − 1) / √(1 − γ₃·SR + (γ₄ − 1)/4 · SR²) )

Here Φ is the normal distribution, SR the observed Sharpe ratio per day, SR\* the benchmark, n the days, γ₃ the skew and γ₄ the kurtosis.

03The deflated Sharpe ratio

The deflated Sharpe ratio (DSR) is the PSR with the benchmark raised to what the best of N trials of no skill would show, N being every trial the ledger counts for the strategy. The more trials, the higher the bar.

That bar is the expected maximum Sharpe ratio of N trials whose true Sharpe ratio is zero, given how much the trials' Sharpe ratios varied:

SR\* = √V · ( (1 − γ)·Φ⁻¹(1 − 1/N) + γ·Φ⁻¹(1 − 1/(N·e)) )

Here V is the variance of the trials' Sharpe ratios and γ is the Euler–Mascheroni constant (≈ 0.5772).

Reading it: 0.95 or above is commonly read as a result unlikely to be only the best of many tries. Well below it, the best cell may be luck. 0.95 is the literature's convention, not a rule.

04The minimum backtest length

How many years of history a result needs before a Sharpe ratio this high is unlikely to be the best of N tries by chance. With few years and many trials, a high Sharpe ratio is expected from luck alone. If your history is shorter than the minimum, the result says little whatever it is.

05The Harvey–Liu haircut

The Sharpe ratio's p-value corrected for N trials (here by Bonferroni, the strictest correction), and the Sharpe ratio a day after that haircut, with the share it lost. A strategy whose Sharpe ratio loses most of itself to the haircut was found, not proven.

06The probability of backtest overfitting

The PBO asks how often the cell that looked best on one part of the days ranks at or below the median of the cells on the other part. Bentrix computes it by combinatorially symmetric cross-validation:

  1. the batch's days are cut into blocks;
  2. every way of splitting the blocks into two halves is tried;
  3. on each split, the cell with the best Sharpe ratio on one half is ranked, by its Sharpe ratio, on the other.

The PBO is the share of splits where it ranks at or below the median. 0.10 or below is commonly read as acceptable, again a convention. A PBO near 0.5 says choosing the best cell is no better than choosing at random.

07The interquartile mean, and the baseline

  • The interquartile mean of the cells' nets is the mean of the middle half, sorted, the 25 % at each end left out. It says what a typical cell made, unmoved by one lucky or one disastrous cell. Its interval comes from a bootstrap with a fixed seed, so it is the same every time.
  • The baseline is the first market's own price change over the days: what simply holding it would have done. A strategy that trails its baseline added nothing but costs.

08Family tests

When you have several candidates — several strategies, or several settings you are choosing between — the honest question is whether the best of them beats a benchmark, allowing for the fact that it was the best of several. Give each candidate's performance less the benchmark's, period by period: one row a candidate, every row the same length, larger being better. Bentrix answers two tests over one stationary bootstrap, drawn the same for every candidate:

  • Hansen's test for superior predictive ability (SPA): the consistent p-value, with the liberal (lower) one and the conservative (upper) one. The conservative p-value is White's reality check. A small p-value says at least one candidate beats the benchmark beyond what the best of that many would by chance.
  • The Romano–Wolf stepdown: an adjusted p-value for each candidate, so you can see which ones beat the benchmark, not only whether any does.

The bootstrap's mean block length is 10 periods unless you set it, which keeps short runs of good or bad periods together. It draws 1,000 resamples unless you set it, up to 20,000, from seed 1 unless you set another. The same series and seed give the same answer. A family larger than 200,000,000 candidate × period × resample cells is refused, with its size.

09From a program

batch_get's statistics, optimisation_import's judgement, and stats_family_test (pure arithmetic: it reads and writes nothing). See the SDK guide on testing honestly.

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed