Lesson 8 of 15

Sharpe & Sortino Ratios

Sharpe & Sortino Ratios

Risk-adjusted return metrics let you compare strategies that have different risk profiles.

Sharpe Ratio — excess return per unit of total risk (annualized): Sharpe=rˉrfσ×252\text{Sharpe} = \frac{\bar{r} - r_f}{\sigma} \times \sqrt{252}

where rˉ\bar{r} is the mean daily return, rfr_f is the daily risk-free rate, and σ\sigma is the sample std of daily returns.

Sortino Ratio — penalizes only downside volatility: Sortino=rˉrfσdown×252\text{Sortino} = \frac{\bar{r} - r_f}{\sigma_{down}} \times \sqrt{252}

where σdown\sigma_{down} is the sample std computed only over returns below rfr_f (the "downside deviation").

The Sortino ratio is preferred when return distributions are asymmetric, because upside volatility is not a risk — it's a reward.

Your Task

Implement:

  • sharpe_ratio(returns, rf=0.0) — annualized Sharpe ratio
  • sortino_ratio(returns, rf=0.0) — annualized Sortino ratio using downside std
Python runtime loading...
Loading...
Click "Run" to execute your code.