The Claude Quant PlaybookDownload ebookDownload ebook

Sortino ratio

intermediateRisk and portfolio2 of 13

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.

Build a trading system with Claude.Download ebook

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

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

  1. Pick a target (zero, the risk-free rate, or a required return).
  2. For each return keep only the shortfall ; returns above become zero.
  3. Square, average and take the square root: that is the downside deviation .
  4. 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 AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.