Investment Portfolio
How should you allocate capital across assets to balance return and risk? Markowitz mean-variance optimization provides the mathematical foundation, while robust extensions guard against estimation uncertainty.
The Problem
Balancing expected return against portfolio risk
Given n assets with expected returns μ and covariance matrix Σ, allocate capital weights w to maximize expected return while controlling portfolio variance. The classic Markowitz mean-variance framework solves:
subject to ∑wi = 1 // fully invested
wi ≥ 0 // no short selling
The parameter λ (risk aversion) controls the tradeoff: high λ penalizes variance heavily, producing conservative portfolios; low λ chases higher returns.
The robust extension adds an uncertainty penalty on expected returns, acknowledging that μ is estimated with error. With ellipsoidal uncertainty:
subject to ∑wi = 1, wi ≥ 0
Try It Yourself
Edit assets, returns, and covariance — then compare optimization methods
Portfolio Optimizer
4 Assets · λ = 2.0| Name | Return (%) |
|---|
| Algorithm | E[Return] | Std Dev | Sharpe | Time |
|---|
The Algorithms
From naive heuristics to quadratic programming
Equal Weight (1/n)
HeuristicAllocate equally across all assets. Despite its simplicity, the 1/n rule is often surprisingly competitive due to diversification benefits and avoidance of estimation error in returns and covariances.
Minimum Variance
HeuristicFind the portfolio with lowest variance, ignoring expected returns entirely. For the unconstrained case (allowing negative weights), the closed-form is w = Σ-11 / (1TΣ-11). With non-negativity constraints, we use projected gradient descent.
Maximum Return
HeuristicConcentrate 100% of capital in the single asset with the highest expected return. This is the most aggressive strategy with zero diversification — maximum return but also maximum concentration risk.
Mean-Variance QP
ExactSolve the full Markowitz objective max μTw − λ·wTΣw using projected gradient descent. The gradient ∇f = μ − 2λΣw is projected onto the probability simplex after each step. Converges to the global optimum since the objective is concave.
Real-World Complexity
Why production portfolio optimization goes far beyond this demo
Beyond Mean-Variance
- Transaction costs — bid-ask spreads and commissions make frequent rebalancing expensive; turnover constraints are essential
- Tax implications — capital gains taxes create path-dependent optimization; tax-loss harvesting adds integer variables
- Liquidity constraints — large positions cannot be liquidated instantly; market impact models are needed
- Thousands of assets — institutional portfolios span thousands of securities; covariance estimation requires factor models
- Dynamic rebalancing — multi-period stochastic optimization replaces single-period Markowitz in practice
- Factor models — Fama-French, APT, and statistical factor models reduce dimensionality and improve estimation
- ESG constraints — environmental, social, and governance screens add exclusion and tilt constraints
- Tail risk (CVaR) — variance fails to capture fat tails; Conditional Value-at-Risk provides asymmetric risk measures
Key References
Foundational papers in portfolio theory
- (1952). "Portfolio selection." The Journal of Finance, 7(1), 77–91. The foundational paper establishing mean-variance optimization as the basis of modern portfolio theory.
- (2003). "Robust portfolio selection problems." Mathematics of Operations Research, 28(1), 1–38. Introduces robust formulations using ellipsoidal and polyhedral uncertainty sets for expected returns.
Need Sophisticated Portfolio Optimization?
From multi-asset allocation to risk budgeting and robust optimization, real investment problems demand rigorous mathematical modeling and domain expertise. Let's discuss your portfolio challenges.