skfolio.measures.expected_max_sharpe_ratio#

skfolio.measures.expected_max_sharpe_ratio(n_trials, trial_sharpe_ratio_std, trial_sharpe_ratio_mean=0.0)[source]#

Approximate the expected maximum Sharpe ratio across independent trials.

When a strategy is selected as the best of several trials, its Sharpe ratio is the maximum of a sample and is therefore inflated by the selection itself.

The formula below approximates this expected maximum. It assumes that the trial Sharpe ratios are independent and follow the same normal distribution:

\[SR_0 = \mu + \sigma \left[(1 - \gamma) \, Z^{-1}\left(1 - \frac{1}{N}\right) + \gamma \, Z^{-1}\left(1 - \frac{1}{N e}\right)\right]\]

with \(N\) the number of trials, \(\mu\) and \(\sigma\) the mean and standard deviation of the trial Sharpe ratios, \(\gamma\) the Euler-Mascheroni constant, \(e\) Euler’s number and \(Z^{-1}\) the inverse standard normal CDF.

The Deflated Sharpe Ratio uses this benchmark with \(\mu = 0\), representing trials whose true Sharpe ratios are zero.

Parameters:
n_trialsfloat

Number of independent trials \(N\), which can be fractional when estimated as an effective trial count. Must be finite and at least 1.

trial_sharpe_ratio_stdfloat

Standard deviation \(\sigma\) of the trial Sharpe ratios, measuring how much they vary from one trial to another. Must be finite and non-negative.

trial_sharpe_ratio_meanfloat, default=0.0

Mean \(\mu\) of the Sharpe ratios across the trials.

Returns:
valuefloat

Approximate expected maximum Sharpe ratio, in the same per-period terms as trial_sharpe_ratio_std and trial_sharpe_ratio_mean.

Raises:
ValueError

If n_trials is not a finite real number greater than or equal to 1, or trial_sharpe_ratio_std is not a finite, non-negative real number.

Notes

With a single trial or without dispersion across trials, there is no selection to correct for and trial_sharpe_ratio_mean is returned.

The calculation treats all n_trials trials as independent. Similar parameter settings can produce correlated Sharpe ratios, so counting every setting as an independent trial can overestimate the expected maximum. An estimated effective number of independent trials can be passed as n_trials.

References

[1]

“The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality”. Bailey, D. and Lopez de Prado, M. (2014)