🛡️ Portfolio Risk Lab: Diversification, Correlation, VaR and Expected Shortfall

2D interactive simulation · educational model

Portfolio risk is not the average of asset risks.

The science

Assets. Three assets with illustrative annual expected returns μ and volatilities σ (equities 7 % / 16 %, bonds 3 % / 6 %, gold 3.5 % / 15 %), joined by a correlation matrix you control; covariance Σij = ρijσiσj.

Portfolio. Return μp = w·μ, risk σp = √(wTΣw). If every ρ = 1 this equals the weighted average of volatilities; any ρ < 1 makes it smaller — that gap is the diversification benefit (the only free lunch in finance, Markowitz 1952).

Risk contribution. The Euler decomposition RCi = wi(Σw)i/σp splits σp into parts that add up exactly to it; a small holding of a very volatile, correlated asset can dominate risk.

VaR and CVaR. 4,000 fixed-seed scenarios are drawn as r = μ + Lz with L the Cholesky factor of Σ. Value at Risk is the loss at the chosen percentile; CVaR (expected shortfall) is the mean of losses beyond it. For normal returns VaR = -(μp + zqσp) — shown as the dashed line and checked against the simulation.

Honest simplifications. Returns are jointly normal for one year, so tails are thinner than in real markets; real correlations change over time and rise in crashes (the Crisis preset mimics this crudely); inputs are illustrative, not forecasts. The frontier is approximated from random mixes. This is not investment advice.