<a id="skfolio-measures-deflated-sharpe-ratio"></a>

# skfolio.measures.deflated_sharpe_ratio

<a id="skfolio.measures.deflated_sharpe_ratio"></a>

### skfolio.measures.deflated_sharpe_ratio(returns, trial_sharpe_ratios, risk_free_rate=0.0)

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_ratio`](https://skfolio.org/generated/skfolio.measures.expected_max_sharpe_ratio.html.md#skfolio.measures.expected_max_sharpe_ratio) using
`trial_sharpe_ratio_mean=0.0`. The selected strategy meets a 95% confidence
requirement when $DSR \geq 0.95$.

* **Parameters:**
  **returns** *ndarray 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_ratios** *ndarray 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_rate** *float, default=0.0*
  : Risk-free rate used to compute the excess mean of `returns`.
* **Returns:**
  **value** *float 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 `returns` is a 1D-array, the result is a float.
    If `returns` is a 2D-array, the result is a ndarray of shape (n_assets,).
* **Raises:**
  ValueError
  : If `trial_sharpe_ratios` is not a 1D-array, is empty after dropping NaNs,
    or contains infinite values.

#### SEE ALSO
[`expected_max_sharpe_ratio`](https://skfolio.org/generated/skfolio.measures.expected_max_sharpe_ratio.html.md#skfolio.measures.expected_max_sharpe_ratio)

[`probabilistic_sharpe_ratio`](https://skfolio.org/generated/skfolio.measures.probabilistic_sharpe_ratio.html.md#skfolio.measures.probabilistic_sharpe_ratio)

### Notes

All quantities are per-period, not annualized, and `trial_sharpe_ratios` must
share the frequency of `returns`.

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

* <a id='rf26c7a7a31f9-1'>**[1]**</a> “The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality”. Bailey, D. and Lopez de Prado, M. (2014)

