Sortino ratio
The Sortino ratio is a Sharpe ratio that only counts bad volatility. Returns above the target do not count as risk; only the shortfalls below it go into the denominator.
01The formula
- expected return per year
- the target return: often zero or the risk-free rate
- the return in one period, a random number
- downside deviation: like a standard deviation, but only counting returns below the target
- the shortfall below target, or zero when the return beats it
02See it move
03Where it is used
- Portfolio managerReports it for strategies with lopsided returns, such as option buying or trend following, where big up days would unfairly lower the Sharpe ratio.
- Quant researcherCompares it with the Sharpe ratio to see whether a strategy's volatility comes mostly from gains or from losses.
- Retail traderUses it to judge whether a fund's risk is the kind that hurts, rather than just how jumpy it is.
04Why traders use it
Investors do not mind surprise gains; they mind losses. The Sortino ratio separates the two, so a strategy that occasionally jumps up is not punished as if it occasionally crashed.
05Worked example
Returns averaging 10.0% a year with volatility 20% and a target of 0.0% have a downside deviation of 9.16% and a Sortino ratio of 1.092, against 0.500 for the Sharpe-style ratio. A year below target happens with probability 30.9%.
06How it is built
- Pick a target (zero, the risk-free rate, or a required return).
- For each return keep only the shortfall ; returns above become zero.
- Square, average and take the square root: that is the downside deviation .
- Divide the excess return by it: . For normal returns with .
07The common mistake
Averaging the squared shortfalls over only the losing periods. The downside deviation divides by all periods (the winners count as zero), otherwise it overstates the risk and the ratio is not comparable across strategies.
08In Python and LaTeX
import numpy as np from scipy.stats import norm from scipy.integrate import quad mu, sigma, T = 0.10, 0.20, 0.0 dd2, _ = quad(lambda x: (T - x)**2 * norm.pdf(x, mu, sigma), -np.inf, T) print(round((mu - T) / np.sqrt(dd2), 4))
\text{Sortino} = \frac{\mu - T}{\sigma_D}, \qquad \sigma_D = \sqrt{E\big[\min(R - T,\,0)^2\big]}09Where it fits
Rather not code the maths yourself? Describe your trading idea and let AI build the bot.
Build a bot with AgenKitThe worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.