skfolio.measures.deflated_sharpe_ratio#
- skfolio.measures.deflated_sharpe_ratio(returns, trial_sharpe_ratios, risk_free_rate=0.0)[source]#
Compute the Deflated Sharpe Ratio (DSR).
The DSR estimates the probability that the true Sharpe ratio of a strategy selected as the best of several trials is greater than zero, once the number and dispersion of those trials and the non-normality of the selected returns are accounted for. It is the Probabilistic Sharpe Ratio benchmarked against the expected maximum Sharpe ratio of the search:
\[DSR = PSR\left(SR_0\right)\]with \(SR_0\) computed by
expected_max_sharpe_ratiousingtrial_sharpe_ratio_mean=0.0. The selected strategy meets a 95% confidence requirement when \(DSR \geq 0.95\).- Parameters:
- returnsndarray of shape (n_observations,) or (n_observations, n_assets)
Return series of the selected trial. For a 2D-array, each column is assessed against the same benchmark derived from
trial_sharpe_ratios.- trial_sharpe_ratiosndarray of shape (n_trials,)
Sharpe ratios of every trial evaluated by the search, not only the selected one, since their count and dispersion set the benchmark. They must use the same risk-free rate as
returns.- risk_free_ratefloat, default=0.0
Risk-free rate used to compute the excess mean of
returns.
- Returns:
- valuefloat or ndarray of shape (n_assets,)
Estimated probability that the true Sharpe ratio of the selected trial is greater than zero after accounting for selection across trials. If
returnsis a 1D-array, the result is a float. Ifreturnsis a 2D-array, the result is a ndarray of shape (n_assets,).
- Raises:
- ValueError
If
trial_sharpe_ratiosis not a 1D-array, is empty after dropping NaNs, or contains infinite values.
Notes
All quantities are per-period, not annualized, and
trial_sharpe_ratiosmust share the frequency ofreturns.The benchmark assumes independent, normally distributed trial Sharpe ratios and uses the number of non-NaN trials as the independent trial count. Positively correlated trials, such as a dense grid of similar parameter combinations, may therefore lead to an overly conservative adjustment.
References
[1]“The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality”. Bailey, D. and Lopez de Prado, M. (2014)