Quantitative finance · Convex QP · LP

Markowitz versus CVaR

Variance is convenient. The left tail is what hurts. One of these models is a quadratic programme; the other is a linear one.

With the same assets and the same target return, this page compares classical mean–variance optimisation (a convex quadratic programme) with Rockafellar–Uryasev conditional value-at-risk (a linear programme). The covariance is Ledoit–Wolf shrunk before it is passed to the solver, and crisis replay packs show how the two efficient frontiers and holdings can diverge. Crisis packs default to holding the calm-sample mean return.

OPERATIONAL PROBLEM
Variance penalises upside and downside equally; CVaR concentrates on expected loss in the worst tail scenarios.
DECISION CONTRAST
Solve a mean–variance quadratic programme and a Rockafellar–Uryasev CVaR linear programme on identical returns and target.
READOUT
Compare frontier, tail loss, and holdings across calm and crisis replay packs.

A mean–variance investor pays for variance, including upside variance. A CVaR investor pays for the expected loss in the worst \(1-\alpha\) of scenarios. When returns are roughly elliptical, the two answers often agree. When they are skewed or heavy-tailed, they need not.

The modelling punchline is not that one number is morally better. It is that the tail model remains a linear programme, so it will still be solvable later with integer trading constraints, whereas a cardinality-constrained Markowitz model would be a mixed-integer quadratic programme that this lab’s solver cannot take.

All bundled return packs are labelled illustrative skeletons of generic books. They are not official index histories.

VIEW MATHEMATICAL FORMULATION

Markowitz as a convex QP

Let \(x\) be portfolio weights, \(\mu\) the vector of expected returns, and \(\hat\Sigma\) a positive definite covariance. For a target \(R\):

\[ \min_x \tfrac12 x^\top\hat\Sigma x \quad\text{s.t.}\quad \mu^\top x \ge R,\quad \mathbf{1}^\top x = 1,\quad x_i \ge \underline{x}. \]

The default teaching model has no short sales (\(\underline{x}=0\)). The Hessian passed to HiGHS is \(Q=\hat\Sigma\), and the shared solver compiles this as \(\tfrac12 x^\top Q x\), so the quadratic term is neither doubled nor halved. \(\hat\Sigma\) is a Ledoit–Wolf shrinkage of the sample covariance towards a constant-correlation target, then a tiny ridge if needed so the smallest eigenvalue is at least \(10^{-8}\). A “raw sample” toggle is available to show the pathology of a noisy Hessian.

The target grid runs up to the largest single-asset mean under the long-only bound. A requested target below the risk-minimising return is kept: the return constraint goes slack and the page returns that risk-minimising portfolio, rather than calling the solve infeasible.

CVaR as an LP

CVaR here is of loss \(L_s=-r_s^\top x\), not of return. Following Rockafellar and Uryasev (2000), a threshold \(\zeta\) (VaR at optimality) and slacks \(u_s\ge 0\) give

\[ \min_{x,\zeta,u}\; \zeta + \frac{1}{1-\alpha}\sum_{s=1}^{S} p_s u_s \quad\text{s.t.}\quad u_s \ge L_s-\zeta,\quad \mu^\top x \ge R,\quad \mathbf{1}^\top x=1,\quad x_i\ge\underline{x}. \]

If the pack does not supply weights, \(p_s=1/S\). Axes and the reading line are in loss units (also shown with a simple annualisation for comparison with the target, without compounding).

Sandbox

Mean–variance expected return (annualised)
0.08
CVaR expected return (annualised)
0.08
Mean–variance volatility (annualised)
0.059
CVaR volatility (annualised)
0.062
Mean–variance CVaR (annualised)
0.918
CVaR portfolio CVaR (annualised)
0.9

At annualised target 0.08, mean–variance return is 0.08 and CVaR-portfolio return is 0.08. CVaR of loss at α = 0.95 is 0.9182 versus 0.8996. Largest weight difference: EQ4 at -0.1843.

Return and volatility coordinates for the mean–variance and CVaR portfolios.
CVaR across the target-return grid.
Portfolio weights under the mean–variance and CVaR models.

Simulated loss tail with the selected CVaR threshold.
QuantityMean–varianceCVaR
StatusOptimalOptimal
Expected return (annualised)8%8%
Volatility (annualised)5.9329%6.1956%
CVaR of loss (annualised)91.8203%89.9596%
Checksumpasspass
Spatial teaching view
Solved return, volatility and CVaR coordinates; teaching data only, not investment advice.

Solved return, volatility and CVaR coordinates; teaching data only, not investment advice.

Notes and limits

References

  1. Markowitz, H. (1952). Portfolio selection. The Journal of Finance, 7(1), 77–91.
  2. Rockafellar, R. T. and Uryasev, S. (2000). Optimization of conditional value-at-risk. Journal of Risk, 2(3), 21–41.
  3. Ledoit, O. and Wolf, M. (2004). Honey, I shrunk the sample covariance matrix. The Journal of Portfolio Management, 30(4), 110–119.