量化金融 · 凸 QP · LP

均值-方差与条件风险价值

方差便于计算;真正造成损失的是左尾。其中一个模型是二次规划,另一个是线性规划。

在同一组资产与同一条目标回报下,比较经典均值-方差(凸二次规划)与 Rockafellar–Uryasev 的条件风险价值(线性规划)。协方差先做 Ledoit–Wolf 收缩再交给求解器,并以危机回放包观察两条有效前沿与持仓如何分道。危机包默认沿用平静期的期望回报。

运营问题
方差同时惩罚上行与下行波动;CVaR 聚焦最差尾部情景的预期损失。
决策对照
在相同收益与目标下,求解均值–方差二次规划及 Rockafellar–Uryasev CVaR 线性规划。
解读指标
比较平静与危机回放数据的前沿、尾部损失与持仓。

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.

查看数学形式

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.

均值—方差与 CVaR 投资组合的收益和波动率坐标。
目标收益网格上的 CVaR。
均值—方差与 CVaR 模型下的投资组合权重。

模拟损失尾部及所选 CVaR 阈值。
QuantityMean–varianceCVaR
StatusOptimalOptimal
Expected return (annualised)8%8%
Volatility (annualised)5.9329%6.1956%
CVaR of loss (annualised)91.8203%89.9596%
Checksumpasspass
空间教学视图
已求解的回报、波动与 CVaR 坐标;教学数据,并非投资建议。

已求解的回报、波动与 CVaR 坐标;教学数据,并非投资建议。

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.