The Claude Quant PlaybookDownload ebookDownload ebook

Variance and standard deviation

beginnerProbability7 of 12

Variance measures how spread out the outcomes are around their average. Its square root, the standard deviation, is the typical size of a miss.

Build a trading system with Claude.Download ebook

01The formula

the mean of X, its expected value
how far outcome i is from the mean
the variance: the average squared distance from the mean
the standard deviation: the square root of the variance, in the same units as X

02See it move

03Where it is used

04Why traders use it

Two strategies with the same expected value can feel completely different to run. Variance tells you how wild the ride is, how much capital you need, and how long it takes to tell skill from luck.

05Worked example

A desk makes 20 trades a day, each winning or losing $100 with chance 50% of a win. The day's P&L has mean $0, variance 200,000 dollars squared and standard deviation $447. About 73.7% of days land within one standard deviation of the mean.

06How it is built

  1. Find the mean .
  2. Square each outcome's distance from the mean, so misses above and below both count.
  3. Average the squares, weighting each by its probability: that is the variance.
  4. Take the square root to get back to the original units. A handy form for computing is .

07The common mistake

Mixing up variance and standard deviation units. Variance is in squared units (dollars squared), so it grows with the square of the stake; always take the square root before comparing it with a P&L.

08In Python and LaTeX

import numpy as np
from scipy.stats import binom
n, p, stake = 20, 0.5, 100
k = np.arange(n + 1)
x, q = stake * (2 * k - n), binom.pmf(k, n, p)
mu = (x * q).sum()
var = ((x - mu) ** 2 * q).sum()
print(round(var), round(np.sqrt(var), 2))  # 200000 447.21
\text{Var}(X) = E\big[(X - \mu)^2\big] = \sum_i (x_i - \mu)^2\,P(X = x_i), \qquad \sigma = \sqrt{\text{Var}(X)}

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.