QuantLab / Portfolio and risk

Portfolio optimisation from first principles

Mean-variance optimisation, the efficient frontier, equal weight as a baseline, hierarchical risk parity, risk parity and CVaR optimisation.

Foundational7 min readUpdated portfolio constructionmean-varianceefficient frontierhierarchical risk parityrisk parity

A researcher with ten securities and a spreadsheet of daily returns has to answer one question before anything else: how much of the portfolio goes into each name. That question has a formal answer — an optimal weight vector, given a set of assumptions about expected return and risk — and an informal one, which is that the formal answer is only as good as the assumptions feeding it. This article works through both.

Mean-variance optimisation

Mean-variance optimisationMean-variance optimisation Portfolio construction that chooses weights to maximise expected return for a given variance, or minimise variance for a given return, using the covariance matrix. asks a precise question: for a target expected return, what portfolio weights minimise variance? Formally, given expected returns μ\mu (a vector of length nn) and a covariance matrixCovariance matrix The matrix of pairwise covariances between asset returns that every mean-variance or risk-based portfolio construction method depends on. Σ\Sigma, the problem is

min⁡w  w⊤Σwsubject tow⊤μ=μtarget,1⊤w=1\min_{w} \; w^\top \Sigma w \quad \text{subject to} \quad w^\top \mu = \mu_{\text{target}}, \quad \mathbf{1}^\top w = 1

with ww the weight vector. Solving this for every achievable target return traces out the efficient frontierEfficient frontier The set of portfolios offering the highest expected return for each level of risk, or the lowest risk for each level of expected return. — the set of portfolios that deliver the least variance for their level of expected return. Everything below the frontier is dominated: there exists another portfolio with the same or higher return and less risk.

A worked example. Take three assets with annualised expected returns μ=(8%,11%,6%)\mu = (8\%, 11\%, 6\%) and annualised volatilities (15%,22%,9%)(15\%, 22\%, 9\%), with pairwise correlations of 0.3 (assets 1–2), 0.1 (assets 1–3) and 0.05 (assets 2–3). The covariance matrix follows from Σij=ρijσiσj\Sigma_{ij} = \rho_{ij}\sigma_i\sigma_j. Solving the quadratic program for a target return of 9% produces a weight vector close to w≈(0.42,0.21,0.37)w \approx (0.42, 0.21, 0.37) — a blend that leans on the low-volatility third asset to offset the high-volatility second one, rather than picking the two highest-return assets outright. This is the mechanical output of the optimiser: it does not know which asset “should” perform well, only how the historical covariance structure lets it diversify.

Why equal weight is the baseline, not a strawman

Every optimiser should be measured against the portfolio that requires no estimation at all: equal weight, wi=1/nw_i = 1/n for every asset. This is not a placeholder for “no strategy” — it is a real allocation with its own risk profile, and it has a well-documented habit of matching or beating mean-variance portfolios out of sample, because it makes no bet on which estimated returns are trustworthy.

The reason is estimation error, not model error. Expected returns are the hardest quantity in finance to estimate precisely: a sample mean built on five years of monthly data carries a standard error large enough that many “different” expected returns are statistically indistinguishable from each other. Mean-variance optimisation is unusually sensitive to this — it treats small differences in μ\mu as meaningful signal and can push weights toward extreme, concentrated positions in whichever asset happened to look best in the sample window. Equal weight sidesteps the entire problem by refusing to use μ\mu at all.

Hierarchical risk parity

Hierarchical risk parityHierarchical risk parity A construction method that allocates down a clustering tree built from asset correlations, avoiding the covariance inversion mean-variance requires. (HRP) is a response to a specific weakness of mean-variance optimisation: it requires inverting the covariance matrix, and that inversion becomes numerically unstable as the number of assets grows or as assets become highly correlated — small measurement errors in Σ\Sigma get amplified by the inversion into large, arbitrary weight swings.

HRP avoids inversion altogether. It works in three steps: cluster assets by correlation distance into a dendrogram (assets that move together end up nested near each other), reorder the covariance matrix according to that clustering (a step called quasi-diagonalisation), and then allocate capital recursively down the tree — splitting the current allocation between two branches in inverse proportion to each branch’s variance, rather than solving a matrix equation for the optimal split. The result is a set of weights that respects the correlation structure of the universe without ever computing Σ−1\Sigma^{-1}.

The practical consequence is stability. Because HRP never inverts the covariance matrix, a small change in one correlation estimate produces a small change in the resulting weights, rather than the disproportionate reweighting that mean-variance optimisation can produce from the same perturbation.

Risk parity

Risk parityRisk parity A portfolio construction method that weights assets so each contributes equally to total portfolio risk, rather than equally to capital. targets a different objective from either mean-variance or HRP: instead of minimising variance or avoiding matrix inversion, it weights assets so that each contributes equally to total portfolio risk. The risk contribution of asset ii is

RCi=wi⋅(Σw)iw⊤ΣwRC_i = w_i \cdot \frac{(\Sigma w)_i}{\sqrt{w^\top \Sigma w}}

and risk parity solves for the ww that sets every RCiRC_i equal. In practice this means low-volatility assets receive higher weights than high-volatility ones — the opposite instinct from a naive return-chasing allocation, and one reason risk parity portfolios are often heavier in low-volatility assets. Note that risk parity, like HRP, makes no use of expected returns at all: both are pure risk-allocation methods, which is precisely why they sidestep the estimation-error problem that afflicts mean-variance optimisation.

CVaR optimisation: minimising the tail, not the spread

Variance penalises upside and downside deviations identically, which is a strange property for a “risk” measure when investors mainly care about the downside. CVaR optimisationConditional value at risk The average loss in the tail beyond the value-at-risk threshold; a coherent risk measure, unlike VaR itself. replaces the variance objective with the expected loss in the worst-case tail: given a confidence level (95% or 99% are typical), CVaR is the average loss conditional on the loss already exceeding the corresponding Value at RiskValue at risk The loss threshold a portfolio is expected to exceed with a stated probability over a stated horizon, reported as a positive number. threshold. The optimisation problem becomes

min⁡w  CVaRα(w)subject to the same budget and return constraints\min_{w} \; \text{CVaR}_\alpha(w) \quad \text{subject to the same budget and return constraints}

This has a genuine advantage where return distributions are skewed or fat-tailed — a strategy with occasional large drawdowns can have modest variance but a dangerous tail, and a variance-minimising optimiser will not notice. CVaR optimisation is convex and tractable via linear programming once returns are represented by historical scenarios, which is part of why it has become a standard complement to mean-variance work rather than a replacement for it.

Estimation error: the problem underneath every method

Every method above depends on inputs estimated from a finite sample, and the finiteness matters more than the choice of method. A covariance matrix estimated from TT observations of nn assets becomes unstable as nn approaches TT — with 60 months of data and 50 assets, the sample covariance matrix is close to singular, and its inverse (needed for mean-variance and, less directly, for risk parity) becomes dominated by noise rather than signal. This is exactly why shrinkage estimators such as Ledoit-Wolf shrinkageLedoit-Wolf shrinkage A covariance estimator that blends the sample covariance with a structured target, reducing estimation error when assets are many and the sample is short. exist: they pull the noisy sample covariance matrix toward a more stable structured target, trading a small amount of bias for a meaningful reduction in estimation variance.

The practical response is threefold: use covariance estimators built for stability rather than the raw sample matrix, treat expected-return inputs with more scepticism than expected-risk inputs (return estimates carry far larger relative error), and compare every optimised portfolio against equal weight, risk parity and HRP on the same out-of-sample data before concluding that the extra complexity earned its place. A full treatment of how to measure that out-of-sample performance — Sharpe, Sortino, drawdown and the rest — is covered in risk and return metrics that matter. What happens to a chosen allocation when the market moves sharply is covered separately in scenario and stress testing your allocation.