The Claude Quant PlaybookDownload ebookDownload ebook

Variance of a sum

intermediateProbability8 of 12

The risk of two positions together depends on how they move together. Standard deviations add like the sides of a triangle, with the angle between them set by the correlation.

Build a trading system with Claude.Download ebook

01The formula

the standard deviations of X and Y
the correlation between X and Y, between −1 and 1
twice the covariance: the extra (or reduced) risk from the two moving together

02See it move

03Where it is used

04Why traders use it

It is the maths of diversification. Risks only add up in full when correlation is 1; below that, part of each risk cancels out.

05Worked example

Desk X has daily risk $1,000 and desk Y $1,500, with correlation 0.30. Together their daily risk is $2,037, less than the $2,500 you get by adding them. If they were uncorrelated it would be $1,803.

06How it is built

  1. Write .
  2. Expand the square: .
  3. The last term is twice the covariance, and .
  4. This is the law of cosines for a triangle with sides and and angle between them, where .

07The common mistake

Adding standard deviations instead of variances. is only right when ; for independent risks you add the variances and take the square root.

08In Python and LaTeX

import numpy as np
sx, sy, rho = 1000, 1500, 0.3
s = np.sqrt(sx**2 + sy**2 + 2 * rho * sx * sy)
print(round(s, 2))  # 2037.15
\text{Var}(X + Y) = \sigma_X^2 + \sigma_Y^2 + 2\rho\,\sigma_X \sigma_Y

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.