"Don't Put All Your Eggs in One Basket" — But With Maths
Diversification is one of those ideas that feels obviously true. Spreading your money across multiple investments reduces risk. But it took Harry Markowitz's 1952 paper to formalise why and how much, and the result was worth a Nobel Prize.
The insight is elegant: portfolio risk depends not just on the riskiness of individual assets, but on how they move together. Two volatile assets that move in opposite directions can combine into a surprisingly calm portfolio. The maths of this — covariance matrices, optimisation, and a bit of calculus — is the foundation of modern portfolio management.
Portfolio Return and Risk
For a portfolio of ( n ) assets with weights ( w_1, w_2, \ldots, w_n ):
Expected return:
[ E[R_p] = \sum_{i=1}^{n} w_i E[R_i] = \mathbf{w}^T \boldsymbol{\mu} ]
Portfolio variance:
[ \sigma_p^2 = \sum_{i=1}^{n} \sum_{j=1}^{n} w_i w_j \sigma_{ij} = \mathbf{w}^T \Sigma \mathbf{w} ]
That second formula is the important one. The covariance matrix ( \Sigma ) captures all the pairwise relationships. If assets are perfectly correlated (( \rho = 1 )), diversification provides no benefit. If they are negatively correlated, you get risk reduction for free.
The Efficient Frontier
Imagine plotting every possible portfolio on a graph: expected return on the y-axis, risk (standard deviation) on the x-axis. The upper boundary of this cloud — the set of portfolios that deliver the maximum return for each level of risk — is the efficient frontier.
Any rational investor would choose a portfolio on the frontier. Anything below it is suboptimal: you could get the same return with less risk (or more return with the same risk) by shifting to the frontier.
Finding the frontier is an optimisation problem:
[ \min_{\mathbf{w}} \mathbf{w}^T \Sigma \mathbf{w} \quad \text{s.t.} \quad \mathbf{w}^T \boldsymbol{\mu} = r_{\text{target}}, \quad \mathbf{w}^T \mathbf{1} = 1 ]
Vary the target return and you trace out the entire frontier.
The Minimum-Variance Portfolio
The leftmost point on the efficient frontier — the portfolio with the absolute lowest risk — is the minimum-variance portfolio. Its weights are:
[ \mathbf{w}_{\text{mv}} = \frac{\Sigma^{-1} \mathbf{1}}{\mathbf{1}^T \Sigma^{-1} \mathbf{1}} ]
You need the inverse of the covariance matrix, which is why linear algebra is not optional for quant finance. In practice, inverting a noisy estimated covariance matrix is fraught with problems, which is why techniques like shrinkage estimation (Ledoit-Wolf) are widely used.
The Capital Asset Pricing Model (CAPM)
Markowitz told us how to build optimal portfolios. William Sharpe took the next step: if everyone builds Markowitz-optimal portfolios, what does the market look like?
The CAPM says the expected return of any asset is:
[ E[R_i] = R_f + \beta_i (E[R_m] - R_f) ]
where:
- ( R_f ) is the risk-free rate
- ( E[R_m] ) is the expected market return
- ( \beta_i = \frac{\text{Cov}(R_i, R_m)}{\text{Var}(R_m)} ) measures the asset's sensitivity to the market
What Beta Means
- ( \beta = 1 ): moves with the market
- ( \beta > 1 ): amplifies market moves (tech stocks, cyclicals)
- ( \beta < 1 ): dampens market moves (utilities, consumer staples)
- ( \beta < 0 ): moves opposite to the market (rare)
Beta is computed by running a regression of the asset's excess returns against the market's excess returns. The slope coefficient is beta.
The Security Market Line
The CAPM relationship, plotted with beta on the x-axis and expected return on the y-axis, is the Security Market Line (SML). Assets above the line offer excess return (positive alpha). Assets below it are overpriced.
Finding alpha — return not explained by systematic risk — is the central quest of quantitative investing. The CAPM says alpha should not exist in an efficient market. Empirical evidence says otherwise, which led to factor models.
Factor Models
The CAPM uses a single factor (the market). Reality is more complex. The Fama-French three-factor model adds:
- SMB (Small Minus Big): small-cap stocks tend to outperform
- HML (High Minus Low): value stocks tend to outperform
Modern quant equity strategies use dozens of factors: momentum, quality, low volatility, profitability, and many more. Each factor represents a systematic source of return — or risk, depending on your perspective.
The relationship to regression is direct:
[ R_i - R_f = \alpha + \beta_1 F_1 + \beta_2 F_2 + \cdots + \beta_k F_k + \epsilon ]
The betas measure factor exposures. Alpha is the unexplained excess return. Building and testing factor models is core buy-side quant work.
The Sharpe Ratio
Named after William Sharpe, the Sharpe ratio measures risk-adjusted return:
[ S = \frac{E[R_p] - R_f}{\sigma_p} ]
A Sharpe ratio above 1 is generally considered good. Above 2 is excellent. Above 3 and people start getting suspicious (is it real, or have you overfit?).
The tangency portfolio — the portfolio on the efficient frontier with the highest Sharpe ratio — is theoretically the optimal risky portfolio. According to the CAPM, it should be the market portfolio.
Limitations and Reality
Portfolio theory is elegant but makes strong assumptions:
- Returns are normally distributed (they are not — fat tails)
- Correlations are stable (they spike in crises)
- Covariance matrices can be estimated accurately (they cannot, with typical sample sizes)
These limitations do not invalidate the framework — they make it a starting point rather than an endpoint. Real quant work involves dealing with these messy realities.
Portfolio Theory in Python
import numpy as np # 3-asset portfolio mu = np.array([0.08, 0.12, 0.06]) # Expected returns cov = np.array([ [0.04, 0.006, 0.002], [0.006, 0.09, 0.009], [0.002, 0.009, 0.01] ]) # Equal-weight portfolio w = np.array([1/3, 1/3, 1/3]) port_return = w @ mu port_vol = np.sqrt(w @ cov @ w) sharpe = (port_return - 0.03) / port_vol # Assuming 3% risk-free print(f"Return: {port_return:.2%}, Vol: {port_vol:.2%}, Sharpe: {sharpe:.2f}")
Dive Deeper
Portfolio theory is where linear algebra, optimisation, and statistics converge. Quantt covers the entire journey — from the maths foundations through to constructing and backtesting real portfolios in Python.
For additional reading, Investopedia's Modern Portfolio Theory guide and the CFA Institute's resources are both solid.
Want to go deeper on Portfolio Theory and CAPM: The Maths Behind Diversification?
This article covers the essentials, but there's a lot more to learn. Inside Quantt, you'll find hands-on coding exercises, interactive quizzes, and structured lessons that take you from fundamentals to production-ready skills — across 50+ courses in technology, finance, and mathematics.
Free to get started · No credit card required