Learn Without Walls

Module 12: Bonds & Fixed Income

Where cash flows become deterministic and the math gets delightfully precise

Part III of 5 Module 12 of 22

1. What Is a Bond?

If a stock is a claim on random future cash flows, a bond is a claim on (nearly) deterministic future cash flows. When you buy a bond, you are lending money to the issuer (a government or corporation) in exchange for a contractually specified stream of payments: periodic coupon payments and the return of principal at maturity.

Stats Bridge

A bond's cash flows are constants, not random variables (assuming no default). This makes bond pricing a problem in deterministic discounting rather than stochastic expectation. The only random element is the discount rate itself, which changes as market interest rates move. In this sense, bond pricing is like a regression problem where the response variable (price) is a known function of one parameter (yield).

A standard coupon bond has two types of cash flows:

Finance Term

Par value (face value) = the amount the issuer promises to repay at maturity, typically $1,000. Coupon rate = annual coupon payment / par value. Maturity = the date when principal is repaid. A bond trading at par has price = face value; above par = premium; below par = discount.

1.1 Bond Pricing Formula

The price of a bond is the present value of all its future cash flows, discounted at the market's required yield:

P = ∑t=1n C / (1 + y)t + F / (1 + y)n

where:

The first term is a geometric series (the present value of an annuity) and the second is a simple present value of a lump sum. For a semi-annual bond, all quantities are halved or doubled appropriately: C = (coupon rate / 2) × F, y = annual yield / 2, n = years to maturity × 2.

Stats Bridge

The bond pricing formula is a weighted sum of fixed values, where the weights are the discount factors wt = 1/(1+y)t. These weights form a geometric decay sequence — exactly the kernel of an exponentially weighted moving average (EWMA). Higher yields produce faster decay, giving less weight to distant cash flows.

2. Coupon Bonds vs. Zero-Coupon Bonds

There are two fundamental bond structures, and understanding their difference is critical:

2.1 Coupon Bonds

A coupon bond pays regular interest and returns principal at maturity. Its cash flow stream looks like a combination of an annuity (the coupons) and a lump sum (the principal).

Cash flows: C, C, C, ..., C, C + F

2.2 Zero-Coupon Bonds

A zero-coupon bond pays no coupons at all. You buy it at a discount and receive the face value at maturity. US Treasury bills (T-bills) and Treasury STRIPS are common examples.

Pzero = F / (1 + y)n

The zero-coupon bond is the purest fixed-income instrument: a single cash flow at a single point in time. Every coupon bond can be decomposed into a portfolio of zero-coupon bonds (one for each coupon and one for the principal). This decomposition is called stripping.

Stats Bridge

A coupon bond is a linear combination of zero-coupon bonds, just as a random variable can be decomposed into a weighted sum of basis functions. The zero-coupon bond is the basis element of fixed-income pricing. Knowing the price of every zero-coupon bond (the "zero curve") lets you price any bond — this is analogous to how knowing the complete set of basis functions lets you represent any function in the space.

2.3 Comparison

Feature Coupon Bond Zero-Coupon Bond
Cash flow pattern Annuity + lump sum Single lump sum at maturity
Purchased at Near par (premium or discount) Deep discount to par
Interest rate sensitivity Moderate (coupons reduce duration) Maximum (duration = maturity)
Reinvestment risk Yes — must reinvest coupons None — no interim cash flows
Statistical analogue Mixture of basis functions Single basis function (Dirac delta at maturity)
Common examples US Treasury bonds, corporate bonds T-bills, Treasury STRIPS

3. Yield to Maturity (YTM) as Internal Rate of Return

The Yield to Maturity (YTM) is the single most important number associated with a bond. It is the discount rate that makes the present value of all future cash flows equal to the current market price:

Pmarket = ∑t=1n C / (1 + YTM)t + F / (1 + YTM)n

In other words, YTM is the Internal Rate of Return (IRR) of the bond investment, assuming you hold to maturity and reinvest all coupons at the YTM rate.

Stats Bridge

Solving for YTM is an inverse problem: given the observed price (data) and the known cash flows (model structure), find the parameter (yield) that makes the model fit the data. There is no closed-form solution for coupon bonds — YTM must be found numerically, typically via Newton-Raphson or bisection. This is identical to solving a maximum likelihood equation where the score function has no analytical root.

3.1 Properties of YTM

Key Insight

The inverse relationship between price and yield is not an empirical observation — it is a mathematical identity. It follows directly from the bond pricing formula: as the denominator (1+y)t increases, each discounted cash flow decreases, so the sum (price) decreases. This is as certain as 1/x being a decreasing function of x for x > 0.

3.2 YTM Assumptions and Limitations

YTM makes two strong assumptions:

  1. Hold to maturity: If you sell before maturity, your actual return differs from YTM because the sale price depends on market conditions.
  2. Reinvestment at YTM: Coupon payments are assumed to be reinvested at the YTM rate. If rates fall, reinvestment income is lower — this is reinvestment risk.
Common Pitfall

YTM is not the expected return. It is the return you would earn under the very specific assumption that you hold to maturity and reinvest all coupons at the same rate. In reality, interest rates change continuously, so the reinvestment assumption rarely holds. YTM is a summary statistic, not a forecast. Treat it as you would treat a sample mean: useful but incomplete.

3.3 The Yield Curve

The yield curve plots YTM against maturity for bonds of the same credit quality (typically US Treasuries). Its shape reveals market expectations about future interest rates:

Yield Curve Shape Interpretation Statistical Analogue
Normal (upward sloping) Market expects rates to rise; term premium for longer maturities Increasing conditional mean: E[r | maturity] increases with maturity
Flat Market expects rates to remain stable Constant conditional mean
Inverted (downward sloping) Market expects rates to fall; historically predicts recession Decreasing conditional mean; strong predictor variable for economic contraction
Humped Rates expected to rise then fall Non-monotone conditional mean; quadratic relationship
Key Insight

An inverted yield curve has predicted every US recession in the past 50 years with only one false positive. As a binary classifier for "recession within 12 months," it has a sensitivity of roughly 100% and specificity of approximately 85%. This makes it one of the most powerful economic leading indicators known.

4. Credit Spreads: The Price of Default Risk

Not all bonds are equally safe. A US Treasury bond is considered "risk-free" (the government can always print money to pay its debts). A corporate bond carries credit risk — the possibility that the issuer defaults. The market prices this risk through the credit spread:

Credit Spread = Yieldcorporate − YieldTreasury

This spread is the additional yield investors demand for bearing default risk. It is a direct market estimate of the risk premium.

Stats Bridge

The credit spread is a difference estimator. By subtracting the risk-free yield, we isolate the component of yield attributable to credit risk, just as a difference-in-differences estimator isolates a treatment effect by removing common trends. Wider spreads mean the market perceives higher default probability. The spread can be decomposed: Spread = Default Probability × Loss Given Default + Liquidity Premium + Risk Aversion Premium.

4.1 Credit Spread Magnitudes

Rating Typical Spread (bps) Implied Annual Default Probability Statistical Interpretation
AAA 20–50 ~0.01% Essentially risk-free; spread is mostly liquidity premium
AA 40–80 ~0.02% Very low probability event
A 60–120 ~0.05% Still a tail event
BBB 120–200 ~0.15% Lowest investment grade; cliff edge
BB 200–400 ~0.8% High yield ("junk"); meaningful default risk
B 400–700 ~3% Speculative; default is a realistic scenario
CCC+ 700–1500+ ~10%+ Distressed; significant probability of default

Note: 1 basis point (bp) = 0.01%. So a spread of 200 bps = 2.00%.

5. Credit Ratings as Ordinal Classification

Credit ratings assigned by agencies (S&P, Moody's, Fitch) are an ordinal classification of credit quality. They rank issuers by likelihood of default but do not provide exact probabilities.

Stats Bridge

Credit ratings are an ordinal variable — they have a natural ordering (AAA > AA > A > BBB > ...) but the "distance" between adjacent ratings is not uniform. The jump from BBB to BB (investment grade to junk) is economically much larger than from AA to A. This is exactly the situation where ordinal regression (proportional odds model) is appropriate, and where treating the variable as interval-scaled would be a mistake. The rating scale is like a Likert scale with non-uniform spacing.

5.1 The Rating Scale

S&P Moody's Category Meaning
AAA Aaa Investment Grade Highest quality, minimal credit risk
AA+, AA, AA- Aa1, Aa2, Aa3 Investment Grade Very high quality, very low credit risk
A+, A, A- A1, A2, A3 Investment Grade Upper medium grade, low credit risk
BBB+, BBB, BBB- Baa1, Baa2, Baa3 Investment Grade Medium grade; adequate but vulnerable to downturns
BB+, BB, BB- Ba1, Ba2, Ba3 High Yield (Junk) Speculative elements; subject to substantial credit risk
B+, B, B- B1, B2, B3 High Yield (Junk) Highly speculative
CCC, CC, C Caa, Ca, C Distressed Substantial risk of default or in default
D Default In payment default

5.2 The BBB/BB Cliff

The boundary between BBB- and BB+ is the most consequential threshold in fixed income. Many institutional investors (pension funds, insurance companies, central banks) are mandated to hold only investment-grade bonds. When a bond is downgraded from BBB- to BB+ ("fallen angel"), these investors are forced to sell, causing a sudden price drop.

Common Pitfall

The BBB/BB boundary is a discontinuity in the price function with respect to the ordinal rating. This violates the assumption of smooth, continuous relationships that many statistical models make. A regression of bond prices on numerical rating codes would miss this cliff entirely. You need either a piecewise model or dummy variables that explicitly capture the investment-grade/junk boundary.

6. Duration: The First Derivative

Duration is the single most important risk measure in fixed income. It answers the question: how sensitive is this bond's price to changes in interest rates?

6.1 Macaulay Duration

Macaulay duration is the weighted average time until a bond's cash flows are received, where the weights are the present values of each cash flow:

DMac = (1/P) ∑t=1n t · CFt / (1 + y)t
Stats Bridge

Macaulay duration is literally the expected value (first moment) of the time-to-cash-flow distribution. Define a discrete probability distribution where the "probability" of time t is proportional to the present value of the cash flow at time t. Then DMac = E[T] under this distribution. It is the center of mass of the bond's cash flows in present-value-weighted time.

6.2 Modified Duration

While Macaulay duration is measured in years, modified duration directly measures price sensitivity:

Dmod = DMac / (1 + y)

Modified duration tells you the percentage change in price for a small change in yield:

ΔP / P ≈ −Dmod · Δy

This is a first-order Taylor approximation. The negative sign confirms that price and yield move in opposite directions.

Stats Bridge

Modified duration is the first derivative of log-price with respect to yield: Dmod = −(1/P)(dP/dy). If you think of the bond price as a function P(y), then duration is the slope of this function (in percentage terms). This is identical to the concept of sensitivity analysis — how much does the output change per unit change in the input parameter? In econometrics, duration is the elasticity of price with respect to (1+y).

6.3 Duration Properties

Factor Effect on Duration Intuition
Maturity ↑ Duration ↑ Cash flows extend further into the future
Coupon rate ↑ Duration ↓ More weight on earlier cash flows (coupons)
Yield ↑ Duration ↓ Higher discount rate gives less weight to distant flows
Zero-coupon Duration = Maturity Only one cash flow, at maturity

7. Convexity: The Second Derivative

Duration provides a linear approximation of price changes. But the price-yield relationship is a curve, not a line. The curvature is captured by convexity:

Convexity = (1/P) · d2P / dy2

Convexity is always positive for standard (option-free) bonds, meaning the price-yield curve bows upward. This has a wonderful consequence for bondholders:

Stats Bridge

Convexity is the second derivative of log-price with respect to yield. In the Taylor expansion framework, duration is the first-order term and convexity is the second-order correction. This is exactly analogous to using a second-order Taylor expansion to approximate a nonlinear function: f(x + h) ≈ f(x) + f'(x)h + (1/2)f''(x)h2. The convexity term improves the approximation when Δy is not infinitesimal.

7.1 The Full Taylor Approximation

Combining duration and convexity gives us a second-order approximation of price changes:

ΔP / P ≈ −Dmod · Δy + (1/2) · Convexity · (Δy)2

This is remarkably accurate for yield changes up to about 200 basis points. For larger moves, you would need higher-order terms (third derivative, etc.) — but in practice, the second-order approximation is almost always sufficient.

Key Insight

Positive convexity is always desirable. Two bonds with the same duration but different convexity will perform differently: the bond with higher convexity gains more when rates fall and loses less when rates rise. Investors are willing to pay a premium for convexity (accept a lower yield), which is why convexity has a market price. This is analogous to paying for insurance against large moves.

7.2 Duration and Convexity by Bond Type

Bond Type Duration (years) Convexity Approximation Error
2-year Treasury ~1.9 Low (~5) Negligible — duration suffices
10-year Treasury ~8.5 Moderate (~80) Small for moves < 50bps
30-year Treasury ~19 High (~400) Convexity correction matters for moves > 25bps
30-year zero-coupon 30.0 Very high (~900) Convexity correction essential

8. Python: Bond Pricing, Duration, and Convexity

8.1 Pricing a Coupon Bond

Pythonimport numpy as np

def bond_price(face, coupon_rate, ytm, years, freq=2):
    """
    Price a coupon bond.

    Parameters
    ----------
    face : float        Face value (par), typically 1000
    coupon_rate : float Annual coupon rate (e.g., 0.05 for 5%)
    ytm : float         Annual yield to maturity
    years : float       Years to maturity
    freq : int          Coupon frequency (2 = semi-annual)

    Returns
    -------
    float : bond price
    """
    n = int(years * freq)
    c = face * coupon_rate / freq     # coupon per period
    y = ytm / freq                     # yield per period

    # Present value of coupons (annuity formula)
    if y == 0:
        pv_coupons = c * n
    else:
        pv_coupons = c * (1 - (1 + y) ** (-n)) / y

    # Present value of face value
    pv_face = face / (1 + y) ** n

    return pv_coupons + pv_face

# Example: 10-year, 5% coupon bond at various yields
print("--- Bond Price vs. Yield ---")
print(f"{'Yield':>8} {'Price':>10} {'Premium/Discount':>18}")
for y in [0.03, 0.04, 0.05, 0.06, 0.07]:
    p = bond_price(1000, 0.05, y, 10)
    status = "Par" if abs(p - 1000) < 0.01 else ("Premium" if p > 1000 else "Discount")
    print(f"{y:>7.1%} ${p:>9.2f}   {status}")

8.2 Computing Duration and Convexity

Pythondef bond_analytics(face, coupon_rate, ytm, years, freq=2):
    """
    Compute price, Macaulay duration, modified duration, and convexity.
    """
    n = int(years * freq)
    c = face * coupon_rate / freq
    y = ytm / freq

    # Build cash flow vector
    cash_flows = np.full(n, c)
    cash_flows[-1] += face  # last period includes principal
    periods = np.arange(1, n + 1)

    # Discount factors
    disc = (1 + y) ** (-periods)

    # Price
    pv = cash_flows * disc
    price = pv.sum()

    # Macaulay duration (in periods, then convert to years)
    mac_dur_periods = np.sum(periods * pv) / price
    mac_dur = mac_dur_periods / freq

    # Modified duration
    mod_dur = mac_dur / (1 + y)

    # Convexity
    convexity_periods = np.sum(periods * (periods + 1) * pv) / (price * (1 + y) ** 2)
    convexity = convexity_periods / freq ** 2

    return {
        'price': price,
        'macaulay_duration': mac_dur,
        'modified_duration': mod_dur,
        'convexity': convexity,
    }

# Compare different bonds
bonds = [
    ("2Y 4% Coupon",   1000, 0.04, 0.045, 2),
    ("5Y 4% Coupon",   1000, 0.04, 0.045, 5),
    ("10Y 4% Coupon",  1000, 0.04, 0.045, 10),
    ("30Y 4% Coupon",  1000, 0.04, 0.045, 30),
    ("10Y Zero-Coupon",1000, 0.00, 0.045, 10),
    ("30Y Zero-Coupon",1000, 0.00, 0.045, 30),
]

print(f"{'Bond':>18} {'Price':>8} {'Mac Dur':>9} {'Mod Dur':>9} {'Convex':>9}")
print("-" * 56)
for name, face, cpn, ytm, yrs in bonds:
    a = bond_analytics(face, cpn, ytm, yrs)
    print(f"{name:>18} ${a['price']:>7.2f} {a['macaulay_duration']:>8.2f}y "
          f"{a['modified_duration']:>8.2f}  {a['convexity']:>8.1f}")

8.3 Taylor Approximation vs. Exact Price Change

Pythondef taylor_vs_exact(face, coupon_rate, ytm, years, yield_change):
    """
    Compare first-order (duration), second-order (duration + convexity),
    and exact price changes for a given yield shock.
    """
    analytics = bond_analytics(face, coupon_rate, ytm, years)
    p0 = analytics['price']
    dur = analytics['modified_duration']
    cvx = analytics['convexity']

    # Exact new price
    p1 = bond_price(face, coupon_rate, ytm + yield_change, years)
    exact_change = (p1 - p0) / p0

    # First-order approximation (duration only)
    first_order = -dur * yield_change

    # Second-order approximation (duration + convexity)
    second_order = -dur * yield_change + 0.5 * cvx * yield_change ** 2

    return exact_change, first_order, second_order

# Test with a 30-year bond for various yield shocks
print("--- 30Y 4% Coupon Bond, YTM = 4.5% ---")
print(f"{'dY (bps)':>10} {'Exact':>10} {'Dur Only':>10} {'Dur+Cvx':>10} {'Dur Err':>10} {'D+C Err':>10}")
for bps in [-200, -100, -50, -25, 25, 50, 100, 200]:
    dy = bps / 10000
    exact, fo, so = taylor_vs_exact(1000, 0.04, 0.045, 30, dy)
    print(f"{bps:>+8}   {exact:>+9.2%}  {fo:>+9.2%}  {so:>+9.2%}  "
          f"{abs(fo - exact):>9.4%}  {abs(so - exact):>9.4%}")

9. Risk Decomposition in Fixed Income

A bond investor faces multiple sources of risk. Understanding and decomposing these is essential for portfolio management:

Risk Type Source Measured By Statistical Analogue
Interest rate risk Changes in market yields Duration, convexity Sensitivity of response to a covariate
Credit risk Issuer may default Credit spread, ratings Binary event probability (Bernoulli)
Reinvestment risk Coupons reinvested at unknown rates Duration mismatch Variance of future discount rates
Liquidity risk May not find a buyer at fair price Bid-ask spread Transaction cost / market impact
Inflation risk Real value of cash flows erodes Breakeven inflation rate Signal contamination by a nuisance process
Call risk Issuer may repay early Option-adjusted spread (OAS) Censored observation (early stopping)
Key Insight

For government bonds (Treasuries), interest rate risk dominates. For corporate bonds, credit risk becomes important. For high-yield (junk) bonds, credit risk dominates everything else. This means the same analytical tools — duration and convexity — are much more useful for Treasuries than for junk bonds, where default analysis matters more. Match your analytical tool to the dominant risk factor.

10. Types of Bonds

Bond Type Issuer Key Features Risk Level
US Treasury bonds US Government Risk-free benchmark; highly liquid Lowest (rate risk only)
Treasury Inflation-Protected (TIPS) US Government Principal adjusts with CPI; protects against inflation Low (real rate risk only)
Municipal bonds State/local governments Often tax-exempt; lower yields but higher after-tax return Low to moderate
Investment-grade corporates Corporations (BBB- or higher) Higher yield than Treasuries; credit risk Moderate
High-yield (junk) bonds Corporations (BB+ or lower) Significantly higher yield; meaningful default risk High
Convertible bonds Corporations Can convert to equity; hybrid instrument Moderate (bond + equity option)

11. Summary

This module has established the mathematical foundations of fixed-income analysis through a statistical lens:

Finance Concept Statistical / Mathematical Analogue
Bond price Weighted sum with exponentially decaying weights
Zero-coupon bond Basis function of the fixed-income space
Yield to Maturity IRR = solving an inverse problem (like MLE)
Credit spread Difference estimator isolating default risk
Credit ratings Ordinal variable with non-uniform spacing
Macaulay duration First moment (E[T]) of PV-weighted cash flow distribution
Modified duration First derivative: −(1/P)(dP/dy)
Convexity Second derivative: (1/P)(d²P/dy²)
Price approximation Second-order Taylor expansion
Yield curve inversion Binary classifier for recession with ~100% sensitivity

With stocks (random cash flows) and bonds (deterministic cash flows) under our belt, we are ready for the most mathematically rich asset class: options and derivatives. In Module 13, we will see how truncated distributions, partial derivatives, and stochastic calculus converge to create the Black-Scholes framework.