# 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.

Source: https://learn.tradelabsai.com/portfolio/portfolio-optimization/  
Track: Portfolio and Performance · Level: Advanced · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Portfolio Optimization", https://learn.tradelabsai.com/portfolio/portfolio-optimization/

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

| Objective | Inputs needed | Character |
|---|---|---|
| Mean variance (target return or risk) | Expected returns, covariances | Classic Markowitz. See [Modern Portfolio Theory and the Efficient Frontier](https://learn.tradelabsai.com/portfolio/modern-portfolio-theory/) |
| Maximum Sharpe ratio | Expected returns, covariances | Tangency portfolio. See [Sharpe Ratio](https://learn.tradelabsai.com/portfolio/sharpe-ratio/) |
| Minimum variance | Covariances only | No return forecasts; favours low volatility, low correlation assets |
| Risk parity | Covariances only | Equal risk contributions. See [Risk Budgeting and Risk Parity](https://learn.tradelabsai.com/portfolio/risk-budgeting-and-risk-parity/) |
| Maximum diversification | Volatilities, covariances | Maximises the ratio of weighted volatilities to portfolio volatility |
| Minimum CVaR | Return scenarios | Targets tail losses. See [Expected Shortfall (CVaR)](https://learn.tradelabsai.com/portfolio/expected-shortfall/) |

## 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.

**Example: A tiny change, a big swing**
Two stock funds have the same 16% volatility and a correlation of 0.9. An analyst estimates expected returns of 8.0% and 7.5%. An unconstrained mean variance optimiser, exploiting the high correlation, goes heavily long the first and short the second, because the half point difference looks like a reliable spread to harvest. If the estimates are flipped to 7.5% and 8.0%, well within estimation error, the positions reverse. Neither portfolio is sensible. Adding a no short selling constraint and a maximum weight of 60% produces stable, reasonable allocations. See [Optimization](https://learn.tradelabsai.com/math/optimization/).

## Making optimisation robust

| Technique | Idea |
|---|---|
| Constraints | Weight caps, no shorting, sector limits, turnover limits |
| Shrinkage | Pull estimates toward a simple target, such as equal correlations (Ledoit Wolf for covariances) |
| Black Litterman | Start from market implied returns. See [Black-Litterman Model](https://learn.tradelabsai.com/portfolio/black-litterman-model/) |
| Resampling | Average optimal weights over many simulated input sets |
| Robust optimisation | Optimise for the worst case within a range of inputs |
| Risk based objectives | Avoid return forecasts entirely |
| Hierarchical risk parity | Cluster 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](https://learn.tradelabsai.com/orders/transaction-costs/) and [Rebalancing](https://learn.tradelabsai.com/portfolio/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](https://learn.tradelabsai.com/portfolio/portfolio-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](https://learn.tradelabsai.com/programming/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](https://learn.tradelabsai.com/portfolio/risk-contribution/).

## Continue learning

- Next lesson: [Risk Contribution and Risk Decomposition](https://learn.tradelabsai.com/portfolio/risk-contribution/)
- Previous lesson: [Rebalancing](https://learn.tradelabsai.com/portfolio/rebalancing/)
- Related: [Rebalancing](https://learn.tradelabsai.com/portfolio/rebalancing/): Rebalancing brings a portfolio back to its target weights after markets move. Learn calendar and threshold rebalancing, costs, taxes and the rebalancing premium.
- Related: [Modern Portfolio Theory and the Efficient Frontier](https://learn.tradelabsai.com/portfolio/modern-portfolio-theory/): Modern portfolio theory shows how combining assets can improve return for a given risk. Learn the efficient frontier, minimum variance portfolio and its limits.
- Related: [Black-Litterman Model](https://learn.tradelabsai.com/portfolio/black-litterman-model/): The Black Litterman model starts from market implied returns and blends in an investor's views with stated confidence, producing stable and intuitive portfolios.
- Related: [Risk Budgeting and Risk Parity](https://learn.tradelabsai.com/portfolio/risk-budgeting-and-risk-parity/): Risk parity balances how much risk each asset contributes instead of how much money it holds. Learn risk budgeting, a worked example, leverage and drawbacks.
- Related: [Optimization](https://learn.tradelabsai.com/math/optimization/): Optimisation finds inputs that maximise or minimise an objective, from portfolio weights to strategy settings. Learn the methods and how to avoid overfitting.
- Related: [Covariance and Correlation](https://learn.tradelabsai.com/math/covariance-and-correlation/): Covariance and correlation measure how two assets move together. Learn the formulas, how to read them, why correlations change in crises and their portfolio role.
