Two-asset portfolio variance
The risk of a mix of two assets is not the average of their risks. It depends on how they move together: the less correlated they are, the more their ups and downs cancel.
01The formula
- the volatility of the portfolio
- the shares of money in each asset (here w₂ = 1 − w₁)
- the volatility of each asset
- the correlation between the two assets' returns, from −1 to 1
02See it move
03Where it is used
- Portfolio managerChecks how adding a new holding changes total risk, which depends far more on its correlation than on its own volatility.
- Risk managerBuilds a desk's risk from a covariance matrix: the same formula with every pair of positions.
- Market makerJudges how much a hedge in a related instrument really reduces inventory risk.
04Why traders use it
It is the maths behind diversification. Two risky assets can make a portfolio safer than either one alone, but only if their correlation is low enough.
05Worked example
With 60% in an asset with volatility 20% and the rest in one with volatility 30%, at correlation 0.30, the portfolio's volatility is 19.35%. If they were perfectly correlated it would be 24.00%, so diversification removes 4.65%.
06How it is built
- The portfolio return is .
- The variance of a sum is .
- Write the covariance as to get the formula.
- It is the law of cosines: arrows of length and at an angle with add up to an arrow of length .
07The common mistake
Adding volatilities instead of variances. Volatilities only add when ; for any lower correlation the portfolio is less risky than the weighted average volatility.
08In Python and LaTeX
import numpy as np w = np.array([0.6, 0.4]) s1, s2, rho = 0.2, 0.3, 0.3 C = np.array([[s1**2, rho*s1*s2], [rho*s1*s2, s2**2]]) print(round(np.sqrt(w @ C @ w), 4))
\sigma_p^2 = w_1^2\sigma_1^2 + w_2^2\sigma_2^2 + 2\,w_1 w_2\,\rho\,\sigma_1\sigma_2
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.