TradeLabs AILearn

Portfolio Optimization

Portfolio optimisation uses maths to choose weights that best meet a goal. Learn mean variance, minimum variance, constraints and how to handle estimation error.

Advanced3 min readUpdated 3 Oct 2026
Markdown
Read firstRebalancing
Lesson 24 of 34

Portfolio optimisation is the use of mathematics to choose portfolio weights that best achieve a stated goal, such as the highest expected return for a given risk, the lowest possible volatility or the best risk adjusted return. Optimisers can weigh dozens or thousands of assets, correlations and constraints at once, something no human can do by intuition. Yet their outputs are only as good as their inputs, and with noisy financial data, a naive optimiser can produce portfolios that are concentrated, unstable and worse than simple alternatives.

Common objectives#

ObjectiveInputs neededCharacter
Mean variance (target return or risk)Expected returns, covariancesClassic Markowitz. See Modern Portfolio Theory and the Efficient Frontier
Maximum Sharpe ratioExpected returns, covariancesTangency portfolio. See Sharpe Ratio
Minimum varianceCovariances onlyNo return forecasts; favours low volatility, low correlation assets
Risk parityCovariances onlyEqual risk contributions. See Risk Budgeting and Risk Parity
Maximum diversificationVolatilities, covariancesMaximises the ratio of weighted volatilities to portfolio volatility
Minimum CVaRReturn scenariosTargets tail losses. See Expected Shortfall (CVaR)

The estimation error problem#

Expected returns are extremely hard to estimate. With 16% annual volatility, even 20 years of data leaves a standard error of about 3.6 percentage points on a stock market's average return (16% divided by the square root of 20). Optimisers treat inputs as exact and pile into assets whose returns happen to be overestimated.

Making optimisation robust#

TechniqueIdea
ConstraintsWeight caps, no shorting, sector limits, turnover limits
ShrinkagePull estimates toward a simple target, such as equal correlations (Ledoit Wolf for covariances)
Black LittermanStart from market implied returns. See Black-Litterman Model
ResamplingAverage optimal weights over many simulated input sets
Robust optimisationOptimise for the worst case within a range of inputs
Risk based objectivesAvoid return forecasts entirely
Hierarchical risk parityCluster assets by correlation and allocate through the tree, proposed by Marcos López de Prado

Including costs#

Real optimisers include transaction costs and turnover penalties, so they only trade when the expected improvement exceeds the cost. Without this, rebalancing a frequently optimised portfolio can consume much of its expected advantage. See Transaction Costs and Rebalancing.

A simple, robust baseline#

Studies such as DeMiguel, Garlappi and Uppal (2009) found that many optimised portfolios failed to beat a simple 1 divided by N equal weight portfolio out of sample, once estimation error was accounted for. Any optimisation method should be compared against equal weighting and inverse volatility weighting. See Equal, Value and Volatility Weighting.

Tools#

Python libraries such as PyPortfolioOpt, Riskfolio Lib and cvxpy make optimisation accessible. Their convenience makes it all the more important to understand the assumptions. See Python for Trading.

Frequently asked questions#

What is portfolio optimisation?#

Choosing portfolio weights mathematically to best meet a goal, such as maximising risk adjusted return or minimising volatility, subject to constraints.

Why do optimised portfolios often disappoint?#

Inputs, especially expected returns, are highly uncertain, and optimisers concentrate in assets with overestimated returns, producing unstable portfolios.

Is minimum variance better than mean variance?#

It avoids return forecasts, so it is often more stable out of sample, but it can concentrate in low volatility assets and sectors.

Next, learn how to see which positions drive risk in Risk Contribution and Risk Decomposition.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonRisk Contribution and Risk DecompositionRisk contribution shows how much each position adds to total portfolio risk, including correlations. Learn marginal and total contributions with a worked example.

Mentioned in