Skip to content
UniKit

Portfolio variance calculator

Portfolio variance calculator: supply weights with a covariance matrix, or one return series per asset, to get the portfolio variance and standard deviation, annualised risk, the diversification ratio, each asset’s risk contribution and the minimum-variance weights, with symmetry and positive semi-definiteness checks.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Weights and covariance matrix

Weights are entered as percentages (60 means 60%) and are normalised internally. The matrix takes one asset per row, comma separated, and must be symmetric and (numerically) positive semi-definite.

Portfolio risk

Assets2
Normalised weights60.00% / 40.00%
Portfolio variance (per period)0.031680
Portfolio standard deviation (per period)17.80%
Annualised variance0.380160
Annualised standard deviation61.66%
Weighted average volatility24.00%
Diversification ratio1.3484
Share of risk50.00% / 50.00%
Minimum-variance weights71.19% / 28.81%
Positive definite checkPassed

Risk contribution by asset

AssetWeightVolatility per periodMarginal risk contributionComponent risk contributionShare of risk
Asset 160.00%20.00%0.1483240.08899450.00%
Asset 240.00%30.00%0.2224860.08899450.00%

What this tool does

  • Size the position and compute the portfolio volatility first, instead of looking at each asset’s volatility in isolation.
  • Compare the risk share across weightings to see whether half your capital really carries 80% of the risk.
  • Hand it a set of historical returns in series mode and let the tool build the covariance matrix and the portfolio risk.
  • Use the minimum-variance weights as a benchmark to see how far your current allocation is from the most conservative spread.

Example

Input

Weights 60% and 40%, covariance matrix [[0.04, 0.006], [0.006, 0.09]], monthly

Output

Portfolio variance 0.031680, standard deviation per period 17.80%, annualised standard deviation 61.66%, weighted average volatility 24.00%, diversification ratio 1.3484, share of risk 50.00% / 50.00%, minimum-variance weights 71.19% / 28.81%

The portfolio standard deviation of 17.80% is below the weighted average volatility of 24.00%, and the ratio between them (1.3484) is the benefit of diversification.

Frequently asked questions

Why can’t I just take a weighted average of the variances?

Because assets move together. Portfolio variance has to be written as wᵀΣw, where the off-diagonal covariances capture the co-movement. The lower the correlations, the smaller the portfolio variance — that is exactly where diversification comes from.

Why does the tool require a symmetric, positive semi-definite matrix?

A covariance matrix is symmetric by definition (Cov(i,j) = Cov(j,i)) and must be positive semi-definite, otherwise the variance it implies can go negative. The tool checks this with its own Cholesky factorisation and finds the minimum-variance weights with partial-pivot Gaussian elimination, so an invalid matrix is reported rather than silently producing nonsense.

Why is the share of risk different from the weight?

Weight is the share of capital you put in; the share of risk is what each asset actually contributes to portfolio volatility (w_i × (Σw)_i ÷ σ²). Volatile, highly correlated assets usually contribute more than their weight: a 60/40 split can carry an 85/15 risk split, which means the diversification is thinner than it looks.

How are the minimum-variance weights computed?

Under the constraint that weights sum to one and no shorting is allowed, the minimum-variance portfolio weights are proportional to Σ⁻¹1. The tool solves Σx = 1 with partial-pivot Gaussian elimination and normalises the result. It is the most conservative spread and a useful benchmark, though estimation error in a historical covariance matrix makes it far from robust.

Keywords:portfolio variance calculatorportfolio standard deviationcovariance matrixrisk contributionminimum variance portfoliodiversification ratio组合方差组合标准差协方差矩阵风险贡献最小方差组合分散化比率

Related tools