Capital Asset Pricing Model: Systematic Risk and Beta
The CAPM describes how expected returns relate to risk; specifically, how beta measures a stock's sensitivity to market movements. It's the foundation of modern portfolio theory and the starting point for understanding risk models.
In the 1960s, three economists independently derived one of the most influential models in finance: the Capital Asset Pricing Model (CAPM). William Sharpe (1964) published first; John Lintner (1965) and Jan Mossin (1966) followed with related derivations. CAPM describes the relationship between risk and expected return for securities.
The Core Idea
In a world with many risky assets, investors can diversify away idiosyncratic risk by holding portfolios. But no amount of diversification eliminates systematic risk: risk that affects the entire market.
The CAPM says: the expected return of any asset depends only on its systematic risk, measured by beta.
The CAPM Formula
Where:
- = expected return of asset
- = risk-free rate
- = beta of asset
- = expected return of the market
- = market risk premium
Interpretation: You expect to be compensated for two things:
- The time value of money ()
- The systematic risk you can’t diversify away ()
Beta: Measuring Systematic Risk
Beta measures how much a stock moves relative to the overall market.
- : Stock moves exactly with the market
- : Stock moves 50% more than the market (more volatile)
- : Stock moves half as much as the market (less volatile)
- : Stock has no market exposure
- : Stock moves opposite to the market (possible but rare for individual stocks)
Calculation:
Where is the correlation between the stock and the market.
Security Market Line (SML)
The Security Market Line is the visual representation of the CAPM:
Plot on the y-axis, on the x-axis:
- The line intercepts at (when )
- Slope = market risk premium
Undervalued assets: Stocks above the SML (higher return for same beta) Overvalued assets: Stocks below the SML (lower return for same beta)
Limitations of CAPM
The CAPM is elegant but has known weaknesses:
1. Single-factor model: Real returns are affected by more than just the market (size, value, momentum, etc.)
2. Betas are unstable: A stock’s beta estimated from historical data may not predict future beta
3. Market portfolio is unobservable: We use stock market indices as proxies, but the true market portfolio includes all risky assets
4. Assumes normal returns: Actual returns have fat tails and skewness
5. Ignores idiosyncratic risk: Later research (Fama-French) showed idiosyncratic risk matters too
Multi-Factor Models
The Fama-French Three-Factor Model extended CAPM by adding two factors:
- SMB (Small Minus Big): Returns of small-cap stocks minus large-cap stocks
- HML (High Minus Low): Returns of high book-to-market stocks minus low book-to-market stocks
Later models added more factors (momentum, profitability, investment).
CAPM in Python
import numpy as np
import pandas as pd
from scipy import stats
def calculate_beta(stock_returns, market_returns):
"""
Calculate beta using covariance method.
beta = Cov(stock, market) / Var(market)
`np.cov` defaults to `ddof=1` (sample covariance, dividing by `N - 1`),
while `np.var` defaults to `ddof=0` (population, dividing by `N`). Mixing
them divides by different denominators and biases beta. Use matching `ddof`.
"""
covariance = np.cov(stock_returns, market_returns)[0, 1]
market_variance = np.var(market_returns, ddof=1)
return covariance / market_variance
def calculate_beta_ols(stock_returns, market_returns):
"""
Calculate beta using OLS regression.
R_stock = alpha + beta * R_market + epsilon
"""
slope, intercept, r_value, p_value, std_err = stats.linregress(
market_returns, stock_returns
)
return {
'beta': slope,
'alpha': intercept,
'r_squared': r_value ** 2,
'p_value': p_value,
'std_err': std_err
}
def capm_expected_return(rf, beta, market_return):
"""
Calculate expected return using CAPM.
"""
return rf + beta * (market_return - rf)
def implied_market_premium(rf, expected_return, beta):
"""
Back out the implied market risk premium from observed returns.
"""
return (expected_return - rf) / beta
def security_market_line(betas, rf, market_risk_premium):
"""
Calculate expected returns for a set of betas per the SML.
"""
return rf + np.array(betas) * market_risk_premium
def idyosyncratic_volatility(stock_returns, market_returns):
"""
Calculate idiosyncratic (residual) volatility after accounting for market.
"""
slope, intercept, _, _, _ = stats.linregress(market_returns, stock_returns)
predicted = intercept + slope * market_returns
residuals = stock_returns - predicted
return np.std(residuals)
PROMPT
Use numpy, pandas, and scipy to calculate CAPM beta from stock and market returns with both the covariance method and OLS regression, plus helpers for expected return, the SML, and idiosyncratic volatility.
Why CAPM Matters for Quants
Despite its limitations, CAPM remains foundational because:
- Benchmark: CAPM’s market beta is still the first risk factor considered in any portfolio
- Discount rate: CAPM (and its multi-factor extensions) is how we estimate the cost of equity for DCF valuations
- Risk budgeting: Portfolio risk decomposition often starts with market beta
- Factor investing: CAPM opened the door to factor-based investing, understanding systematic risk factors is how quant strategies are built
References
- Sharpe, “Capital Asset Prices.” Journal of Finance, 1964.
- Lintner, “Security Prices and Maximal Gains from Diversification.” Review of Economics and Statistics, 1965.
- Fama, French, “The Cross-Section of Expected Stock Returns.” Journal of Finance, 1992.
- Bodie, Kane, Marcus, Investments, Ch. 8-9. McGraw-Hill, 2020. ISBN: 978-1-26-057101-6.