Trading Dev AcademyFree quant education

Free lesson · Portfolio management theory

Mean–variance theory and the efficient frontier

Open interactive lessonPractice calculationsExplore labs

Start with the idea

A portfolio is a joint distribution of returns, not a collection of individually attractive trades. Mean–variance theory balances expected return against portfolio variance under an explicit preference or target.

Symbols, units & horizon
  • w: n-vector of portfolio weights on one capital base
  • μ: expected returns over a fixed horizon
  • Σ: covariance matrix over that same horizon
  • T: transpose
  • σ_p²: portfolio variance
  • λ: positive risk-aversion scaling
  • J: quadratic utility approximation
  • Final equation: unconstrained optimum with positive-definite Σ, no budget constraint

When and why to use this

Use mean–variance theory as a transparent benchmark for converting forecasts and correlations into portfolio choices.

Expected portfolio return is linear in weights, while variance includes every pairwise covariance. Diversification depends on joint behaviour, not the number of names. The efficient frontier contains portfolios for which no feasible alternative offers higher expected return at the same variance, under the chosen inputs and constraints.

The simplest unconstrained quadratic objective has a closed-form first-order condition. A fully invested portfolio also requires weights to sum to one, and real portfolios add gross, net, sector, liquidity and financing constraints. Short-sale restrictions change the feasible frontier.

Expected returns are difficult to estimate. An optimiser can magnify tiny input errors into extreme weights, especially when covariance is poorly conditioned. Compare against equal-weight, minimum-variance and simple risk-budget baselines using the same rebalance schedule.

E[Rp]=w𝖳μ,σp2=w𝖳Σw,J=w𝖳μ−λ2w𝖳Σw,λΣw=μ
Model assumptions, derivation and arithmetic

Mean–variance theory and the efficient frontier

  1. Expand portfolio return as Σ_i w_i r_i. Linearity gives expected return wᵀμ.
  2. Expand its squared centred return and take expectations to obtain Σ_iΣ_j w_iw_j Cov(r_i,r_j)=wᵀΣw.
  3. Differentiate J: μ−λΣw=0 for symmetric Σ. Solve λΣw=μ. Add constraints through a constrained optimisation problem rather than silently normalising this solution.
Work it by hand

With independent assets, μ=[.04,.06], variances [.04,.09] and λ=2, unconstrained weights are [.5,1/3]. Their sum is 5/6 because no fully-invested constraint was imposed.

Apply it in a strategy

  • Align forecast horizon, return units and capital convention before estimating μ and Σ.
  • Specify the feasible set and compare several simple allocation baselines.
  • Stress input estimates and evaluate realised risk, turnover and costs on future periods.

Research deliverable

Show an efficient-frontier or risk/return comparison with the exact constraints and input-estimation method stated.

Research sources, review dates and limitations

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

import numpy as np

def unconstrained_mean_variance(means,covariance,risk_aversion):
    mu=np.asarray(means,float); cov=np.asarray(covariance,float)
    if risk_aversion<=0 or cov.shape!=(len(mu),len(mu)): raise ValueError("Invalid inputs")
    return np.linalg.solve(risk_aversion*cov,mu)

print(unconstrained_mean_variance([.04,.06],[[.04,0],[0,.09]],2))

Continue learning

Portfolio Theory: Estimation, Risk Budgets & Rebalancing — all lessons
  1. Mean–variance theory and the efficient frontier
  2. Covariance estimation, shrinkage and fragile allocations
  3. Regime uncertainty: combine scenarios before allocating
  4. Marginal risk, risk contributions and strategy overlap
  5. Bayesian views, forecast uncertainty and robust decisions
  6. Turnover, no-trade regions and dynamic portfolio management

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations