BLOG / Quant 12W · Factor Investing · 2026-12-03
Where CAPM Comes From: From Mean-Variance to the Security Market Line
EXECUTIVE DEFINITION & EMPIRICAL ANCHOR
Beta is a marginal risk ratio, not an empirical rule of thumb. Full derivation from Sharpe maximization to SML and five equilibrium assumptions.
Every financial portal quotes market beta, yet few explain why beta equals covariance divided by market variance rather than standalone volatility. Beta is not an empirical rule of thumb: it is the exact marginal volatility contribution ∂σ_M/∂w_i divided by σ_M when every investor holds the same mean-variance tangency portfolio.
Formula Anatomy & Practitioner Intuition
CAPM Security Market Line & Marginal Risk Contribution
$$\mathbf{w}^* = \frac{\boldsymbol{\Sigma}^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})}{\mathbf{1}^\top \boldsymbol{\Sigma}^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})}, \quad E[R_i] - r_f = \beta_i\bigl(E[R_M] - r_f\bigr), \quad \frac{\partial \sigma_M}{\partial w_i} = \frac{(\boldsymbol{\Sigma}\mathbf{w}_M)_i}{\sigma_M} = \beta_i \sigma_M$$
(1)
Intuition: Maximizing the portfolio Sharpe ratio against a risk-free rate r_f sets tangency weights w* proportional to Σ⁻¹(μ − r_f 1). Under homogeneous expectations and market clearing, w* equals the market portfolio M. Shifting an infinitesimal weight ε into asset i raises market volatility at rate β_i σ_M, so equilibrium prices only systematic covariance with M.
Worked Example: Exact 4-asset equilibrium fixture (replicate_w50.py, r_f = 3.0%): solving w* ∝ Σ⁻¹(μ − r_f 1) yields market excess return 5.7554% and market volatility 14.7138%. Across all four assets, the Security Market Line identity E[R_i] − r_f = β_i(E[R_M] − r_f) holds to max discrepancy 1.39 × 10⁻¹⁷, and central finite differences of ∂σ_M/∂w_i match β_i σ_M to 7.90 × 10⁻¹¹.
Five Explicit Equilibrium Assumptions: single-period mean-variance horizon, homogeneous expectations, frictionless markets, unrestricted borrowing/lending at r_f, and market clearing. Relaxing borrowing constraints flattens the SML (Black, 1972; Frazzini & Pedersen, 2014), and Roll (1977) proved the true market portfolio is unobservable.
WORKED REAL-MARKET SUBSTITUTION · LIVE SNAPSHOT (2026-12-03)
Plugging Real US Stocks Into the Equation ($100,000 Position)
Every figure below is computed deterministically from our 2026-12-03 split/dividend-adjusted daily snapshot — zero hypothetical fills.
Empirical Market Visuals (Top 500 US Equities Snapshot)
INTERACTIVE FORMULA SANDBOX (<16ms LOCAL RECOMPUTE)
Test Your Own Position Size & Stress Parameters
SPY Shock (%)—
Position Size (USD)—
Static / Naive Estimate
—
Conditioned Model Output
—
Hidden Risk Gap
—
THIS POST'S METRIC FOR ANY TICKER · PRECOMPUTED SNAPSHOT · 2020-01-02 to 2026-12-03
MSFT · Static OLS β = 1.13 · R² = 0.56 · Market-model α on raw daily returns (r_f not subtracted), ×252 = 3.77%
Looked up from the precomputed daily snapshot (as of 2026-12-03); nothing is re-estimated in your browser.
Step-by-Step Mathematical Derivation & Vectorized Reference Spec (Click to Expand Full Proofs)
Step 1. Step 1 — Portfolio variance: standalone variance enters scaled by w_i^2, while cross-covariances dominate in diversified books.
$$\mu_p = \mathbf{w}^\top \boldsymbol{\mu}, \qquad \sigma_p^2 = \mathbf{w}^\top \boldsymbol{\Sigma} \mathbf{w}$$
(2)
Step 2. Step 2 — Tangency portfolio: differentiating Sharpe ratio S(w) and setting gradient to zero produces w* proportional to Sigma^-1(mu - r_f 1).
$$S(\mathbf{w}) = \frac{\mathbf{w}^\top(\boldsymbol{\mu} - r_f\mathbf{1})}{\sqrt{\mathbf{w}^\top\boldsymbol{\Sigma}\mathbf{w}}}, \qquad \mathbf{w}^* = \frac{\boldsymbol{\Sigma}^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})}{\mathbf{1}^\top\boldsymbol{\Sigma}^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})}$$
(3)
Step 3. Step 3 — Market clearing: homogeneous expectations mean every investor holds the same risky proportions w*, so aggregate supply equals demand only if w* = w_M.
$$\mathbf{w}^* = \mathbf{w}_M, \qquad R_M = \mathbf{w}_M^\top \mathbf{R}$$
(4)
Step 4. Step 4 — Perturbation proof of the SML: shifting weight epsilon into asset i touches the Capital Market Line tangentially at epsilon = 0.
$$\frac{\left.d\mu/d\varepsilon\right|_{\varepsilon=0}}{\left.d\sigma/d\varepsilon\right|_{\varepsilon=0}} = \frac{E[R_i]-E[R_M]}{(\operatorname{Cov}(R_i,R_M)-\sigma_M^2)/\sigma_M} = \frac{E[R_M]-r_f}{\sigma_M} \;\Longrightarrow\; E[R_i]-r_f = \beta_i(E[R_M]-r_f)$$
(5)
Step 5. Step 5 — Marginal risk contribution: beta is covariance divided by market variance because adding asset i expands market volatility at rate beta_i * sigma_M.
$$\frac{\partial \sigma_M}{\partial w_i} = \frac{(\boldsymbol{\Sigma}\mathbf{w}_M)_i}{\sqrt{\mathbf{w}_M^\top\boldsymbol{\Sigma}\mathbf{w}_M}} = \frac{\operatorname{Cov}(R_i,R_M)}{\sigma_M} = \beta_i \sigma_M$$
(6)
REFERENCE VECTORIZED SPEC (NUMPY)
import numpy as np
def verify_capm_equilibrium(mu, Sigma, rf=0.03):
excess = mu - rf
raw = np.linalg.solve(Sigma, excess)
w_m = raw / raw.sum()
mu_m = float(w_m @ mu)
sigma_m = float(np.sqrt(w_m @ Sigma @ w_m))
cov_im = Sigma @ w_m
betas = cov_im / (sigma_m ** 2)
sml_err = np.max(np.abs((mu - rf) - betas * (mu_m - rf)))
mrc = cov_im / sigma_m # equals betas * sigma_m
return dict(w_m=w_m, mu_m=mu_m, sigma_m=sigma_m, betas=betas, sml_err=sml_err, mrc=mrc)
WHERE THIS MODEL BREAKS (HONEST FAILURE REGIMES)
1) Roll (1977): the true all-asset market portfolio is unobservable, so empirical tests jointly test CAPM and the proxy index. 2) Borrowing constraints flatten the SML (Black, 1972; Frazzini & Pedersen, 2014). 3) Single-period myopia ignores regime shifts in rates and volatility (Merton, 1973). 4) Fat-tailed crash skewness requires downside beta and Expected Shortfall rather than symmetric variance alone.
QUANT DESK INTERVIEW CHECK
Desk Check (CAPM Marginal Risk): In a mean-variance equilibrium where the market portfolio has volatility σ_M = 15%, what is the marginal contribution ∂σ_M / ∂w_i of an asset with market beta β_i = 1.40?
Technical Questions & Answers (3)
How is CAPM derived from mean-variance optimization?
Maximizing the Sharpe ratio yields a single tangency portfolio w* ∝ Σ⁻¹(μ − r_f 1). Under homogeneous expectations and market clearing, w* equals the market portfolio w_M, forcing every asset's excess return to equal β_i times the market premium.
Why is beta equal to covariance divided by market variance?
Differentiating market portfolio volatility σ_M with respect to weight w_i gives Cov(R_i, R_M)/σ_M = β_i·σ_M. Thus β measures an asset's marginal contribution to systematic market risk.
Does CAPM require asset returns to be normally distributed?
Not strictly: quadratic utility or elliptical return distributions (including Student-t with finite variance) also preserve mean-variance preference, though real-world leverage constraints flatten the empirical SML.
EMPIRICAL VERIFICATION
Test this exact metric on your own US equity holdings
Deterministic 2020–2026 daily snapshot · Free 10s portfolio audit · No signup required
US daily equities (split & dividend adjusted; includes public Yahoo Finance market data through 2026-12-03) · 2020-01-02 to 2026-12-03 · Open Access — Zero Paywall.