06 — Portfolio Construction

Mean-Variance Optimization#

Efficient FrontierMathematical1 min read
◆ The PatternMarkowitz efficient frontier — balance return against portfolio variance

The 1952 Markowitz framework maximizes expected return for a given level of risk (or minimizes variance for a target return). The efficient frontier traces optimal portfolios.

min ½ w′ Σ w   s.t.   w′ μ ≥ rtarget,   w′ 1 = 1
Estimation error in μ and Σ makes raw MVO unstable — shrinkage estimators (Ledoit-Wolf) and resampling improve robustness. The tangency portfolio maximizes the Sharpe ratio.
// Interactive — risk aversion and efficient frontier
Risk aversion
ApproachFix
ShrinkageReduce estimation noise in Σ
ResamplingAverage across bootstrapped frontiers
Black-LittermanBlend views with equilibrium priors
Pattern bridge: Quadratic programming appears in ML Math — Optimizers.
Worked example

Three assets: stocks (7% expected, 16% volatile), bonds (3%, 5%) and real estate (5%, 12%). The maximum-Sharpe portfolio holds 29% / 57% / 14%. Raise the stocks’ expected return by a single point — well inside anyone’s margin of error — and it becomes 37% / 55% / 8%: real estate nearly halves. The optimizer treats guesses as facts.

Where it misleads
  • Small errors in expected returns produce large swings in weights (Best & Grauer 1991); Michaud (1989) called optimizers “estimation-error maximizers”.
  • Out of sample, simple 1/N weights are hard to beat with sample estimates (DeMiguel, Garlappi & Uppal 2009).
  • Shrinking the covariance matrix (Ledoit & Wolf 2004), adding constraints or starting from market weights (Black–Litterman) makes the results usable.
In code
mu = np.array([0.07, 0.03, 0.05])                         # stocks, bonds, real estate: expected returns
vol = np.array([0.16, 0.05, 0.12])
rho = np.array([[1, 0.1, 0.5], [0.1, 1, 0.2], [0.5, 0.2, 1]])
cov = np.outer(vol, vol) * rho
rf = 0.02

def tangency(mu):                                          # the maximum-Sharpe portfolio
    w = np.linalg.solve(cov, mu - rf)
    return w / w.sum()

base = tangency(mu)
nudged = tangency(mu + [0.01, 0, 0])                       # one point more expected from stocks
Python, in your browser — edit the code and run it again

Assumes import numpy as np and import pandas as pd. Each snippet carries its own example numbers; the comments say which are made up or simulated.

Sources
  • H. Markowitz, “Portfolio Selection”, Journal of Finance 7(1), 1952
  • R. O. Michaud, “The Markowitz Optimization Enigma: Is ‘Optimized’ Optimal?”, Financial Analysts Journal 45(1), 1989
  • M. J. Best & R. R. Grauer, “On the Sensitivity of Mean-Variance-Efficient Portfolios to Changes in Asset Means”, Review of Financial Studies 4(2), 1991
  • V. DeMiguel, L. Garlappi & R. Uppal, “Optimal Versus Naive Diversification: How Inefficient Is the 1/N Portfolio Strategy?”, Review of Financial Studies 22(5), 2009

Last reviewed October 2026 · How this site checks its content · Report a mistake

Linked from 1
← Previous
Tail Risk
Open in the full reader, with the topic sidebar