Skip to content

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.

2 of 31 ~3 min

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

E(Ri)=Rf+βi×(E(Rm)−Rf)E(R_i) = R_f + \beta_i \times (E(R_m) - R_f)

Where:

  • E(Ri)E(R_i) = expected return of asset ii
  • RfR_f = risk-free rate
  • βi\beta_i = beta of asset ii
  • E(Rm)E(R_m) = expected return of the market
  • E(Rm)−RfE(R_m) - R_f = market risk premium

Interpretation: You expect to be compensated for two things:

  1. The time value of money (RfR_f)
  2. The systematic risk you can’t diversify away (βi×(E(Rm)−Rf)\beta_i \times (E(R_m) - R_f))

Beta: Measuring Systematic Risk

Beta measures how much a stock moves relative to the overall market.

  • β=1\beta = 1: Stock moves exactly with the market
  • β=1.5\beta = 1.5: Stock moves 50% more than the market (more volatile)
  • β=0.5\beta = 0.5: Stock moves half as much as the market (less volatile)
  • β=0\beta = 0: Stock has no market exposure
  • β<0\beta < 0: Stock moves opposite to the market (possible but rare for individual stocks)

Calculation:

βi=Cov(Ri,Rm)Var(Rm)=ρi,m×σiσm\beta_i = \frac{Cov(R_i, R_m)}{Var(R_m)} = \rho_{i,m} \times \frac{\sigma_i}{\sigma_m}

Where ρi,m\rho_{i,m} is the correlation between the stock and the market.

Security Market Line (SML)

The Security Market Line is the visual representation of the CAPM:

E(Ri)=Rf+βi×(E(Rm)−Rf)E(R_i) = R_f + \beta_i \times (E(R_m) - R_f)

Plot E(R)E(R) on the y-axis, β\beta on the x-axis:

  • The line intercepts at RfR_f (when β=0\beta = 0)
  • 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:

E(Ri)=Rf+βimkt×(E(Rm)−Rf)+βiSMB×E(RSMB)+βiHML×E(RHML)E(R_i) = R_f + \beta_i^{mkt} \times (E(R_m) - R_f) + \beta_i^{SMB} \times E(R_{SMB}) + \beta_i^{HML} \times E(R_{HML})
  • 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:

  1. Benchmark: CAPM’s market beta is still the first risk factor considered in any portfolio
  2. Discount rate: CAPM (and its multi-factor extensions) is how we estimate the cost of equity for DCF valuations
  3. Risk budgeting: Portfolio risk decomposition often starts with market beta
  4. 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.