Tool

How much of a backtest's Sharpe ratio is luck?

Test enough variants of a strategy and one of them will look good by chance. Enter the Sharpe ratio of the one you picked and how many you tried. You get the deflated Sharpe ratio, the bar luck alone is expected to reach, and how many years of data that many variants need.

Updated

Your backtest

What survives the trials

Deflated Sharpe ratio
90.0% chance that the strategy's true Sharpe ratio is above zero, once 100 variants and the shape of the returns are counted. That is below the 95% bar the paper uses.
What luck alone is expected to reach
A Sharpe ratio of 1.79 a year (0.1132 per return). That is the best of 100 variants with no skill at all, given how far apart your variants' results were.
Minimum backtest length
1.0 year of data before 100 variants stop producing a Sharpe ratio of 2.50 by luck. Your backtest covers 5.0 years.

The address bar keeps your numbers, so you can bookmark a backtest or send it to a colleague. "Copy link to these numbers" copies that address. The calculator runs in your browser and makes no request of its own. If you accepted analytics, the page address, with your numbers in it, is recorded like any other page view.

The numbers it starts with

They are the worked example in the paper that defined the deflated Sharpe ratio. A strategist tries 100 variants of a trading idea on five years of daily data, 1,250 returns. The best one has an annualised Sharpe ratio of 2.5. The variance of the 100 Sharpe ratios is 0.5, the returns have a skewness of -3 and a kurtosis of 10.

The calculator gives a deflated Sharpe ratio of 90.0%. The paper's investor turns the strategy down, because "there is only a 90% chance that the true SR associated with this strategy is greater than zero". Change the variants to 46 and the result is 95.1%, the paper's own figure. With Normal returns, skewness 0 and kurtosis 3, the result stays above 95% up to 88 variants.

How it works it out

The bar luck alone reaches

If every variant had no skill, the best of N of them would still show a Sharpe ratio above zero. Equation 1 of Bailey and López de Prado (2014), in The Journal of Portfolio Management 40(5), gives its expected size. It grows with the number of variants and with how far apart their results were. That value is the threshold, SR0.

The deflated Sharpe ratio

Equation 2 of the same paper. It is the probability that the true Sharpe ratio beats SR0, given the length of the backtest and the skewness and kurtosis of its returns. Fat tails and a long left tail widen the error on a Sharpe ratio, so they lower the result. The formula works per return, so the calculator divides the annual figures by the square root of the returns per year.

The minimum backtest length

Theorem 2 of Bailey, Borwein, López de Prado and Zhu (2014), in the Notices of the American Mathematical Society 61(5). It gives the years of data needed before N skill-less variants stop reaching a given Sharpe ratio by chance. The paper's example, for a Sharpe ratio of 1: with five years of data, "no more than forty-five independent model configurations should be tried".

We test the code against all four figures above.

Where each number comes from

  • Variants you tested. Every version you ran and compared, counting the ones you threw away: other parameters, other markets, other periods. Variants that move together count as fewer independent trials. The paper's third appendix shows how to estimate that number.
  • Variance of their Sharpe ratios. Compute each variant's annual Sharpe ratio, then the variance across them. A wide spread means more room for one to stand out by luck.
  • Skewness and kurtosis. Of the picked strategy's returns, at the same frequency as the Sharpe ratio. Kurtosis here is the plain moment, 3 for Normal returns. By defaultscipy.stats.kurtosis and pandas' kurt() return excess kurtosis, which is that minus 3, so add 3 back.

What the result can't tell you

It assumes the backtest itself is honest. A strategy that reads tomorrow's price, fills at prices nobody offered or skips fees will pass this test and still lose money. The deflated Sharpe ratio corrects for the search. It can't see those faults.

It does not forecast returns. A result above 95% says the Sharpe ratio is unlikely to be pure selection luck, under the papers' assumptions. Markets change, and a real edge can still fade.

If you want someone to check the parts this calculator assumes, that is ourbacktest audit.