Duration and Convexity for Fixed Income Quants

Duration is the first-order sensitivity of a bond price to yield; convexity is the second-order correction that makes the approximation useful beyond infinitesimal moves. They are not merely reporting fields. In a curve-based system they are local derivatives of a pricing function, and their definition must match the curve, compounding convention, and shock used by risk.

Price derivatives and definitions

For cash flows \(CFi\) at year fractions \(ti\), a bond priced off a flat continuously compounded yield \(y\) is

P(y) = Σ CF_i exp(-y t_i)
D_mod = - (1 / P) dP/dy
C = (1 / P) d²P/dy²
ΔP/P ≈ -D_mod Δy + 0.5 C (Δy)²

Macaulay duration is the present-value-weighted average payment time. Under discrete compounding with frequency m, modified duration is D_mac / (1 + y/m). Confusing the two creates a systematic scale error in DV01.

MeasureUnitsPrimary use
Macaulay durationyearscash-flow timing
Modified durationyearsparallel yield sensitivity
DV01 / PV01currency per bphedging and P&L
Key-rate durationcurrency or % per bpcurve-shape risk
Convexityyears²nonlinear yield response
import numpy as np

def bond_risk(cashflows, times, y):
    cf, t = np.asarray(cashflows), np.asarray(times)
    pv = cf * np.exp(-y * t)
    price = pv.sum()
    duration = (pv * t).sum() / price
    convexity = (pv * t**2).sum() / price
    return price, duration, convexity, price * duration * 1e-4

The returned DV01 is positive by market convention: a one-basis-point rise reduces price by approximately that amount.

Why duration is insufficient

At a 100 bp shock, the quadratic term is material for long government bonds. Positive convexity means price gains from falling yields exceed losses from equal yield rises. A callable bond can have negative effective convexity because lower rates increase the probability that the issuer redeems the bond; a mortgage-backed security adds prepayment optionality and needs scenario-based effective duration.

For an instrument whose cash flows change with rates, calculate effective duration:

D_eff = (P_down - P_up) / (2 P0 Δy)
C_eff = (P_down + P_up - 2P0) / (P0 Δy²)

The model must fully revalue the embedded option in each shocked scenario. Applying cash-flow duration to an MBS is not conservative; it is the wrong risk model.

Curves, not a single yield

Production valuation discounts each cash flow from a zero curve. “Yield duration” is then an ambiguous compression of a multi-factor exposure. Key-rate durations bump localized curve nodes, rebuild a smooth curve, and reprice:

def key_rate_dv01(price_fn, curve, node, bump=1e-4):
    up, down = curve.copy(), curve.copy()
    up[node] += bump
    down[node] -= bump
    return (price_fn(down) - price_fn(up)) / 2

The sum of key-rate DV01s approximates parallel DV01 only when bump construction is additive. Use the same interpolation, calendar, and quote convention in risk and valuation; otherwise hedges explain neither P&L nor residual risk.

Hedging and residual exposures

To hedge a bond with a Treasury future, match DV01 after accounting for conversion-factor economics and cheapest-to-deliver uncertainty. A one-instrument hedge removes one factor, not the curve. A barbell and bullet can share duration while having radically different convexity and key-rate profiles. A useful hedge report therefore includes:

RiskTest
Parallelaggregate DV01
Twist2s10s and 5s30s shocks
Curvaturebelly versus wings
Nonlinearityfull-revaluation stress
Modelbump/interpolation stability

Duration also links fixed income to asset allocation: covariance estimates used in portfolio optimization should include rate-factor exposures, not only return correlations.

Key takeaways

  • DV01 is the tradable first-order risk; duration is its normalized form.
  • Convexity improves finite-shock estimates but does not replace full revaluation for options.
  • Key-rate exposures, consistent curves, and scenario tests matter more than a headline duration.

Implementation checklist

Unit-test pricing and derivatives against a finite-difference calculation at several bump sizes. Test coupon dates around weekends, ex-coupon periods, accrued interest, and stub schedules separately: a correct derivative of an incorrect clean-price function is still incorrect risk. Persist the curve snapshot and instrument conventions used for each daily risk run so that unexplained P&L can be reproduced.

For stress testing, use nonparallel historical curve moves as well as arbitrary 25, 50, and 100 bp shocks. Report the approximation error between delta-gamma and full-revaluation P&L. The error itself is a risk diagnostic: it identifies bonds where optionality, large moves, or inconsistent bump construction make linear risk reporting unsafe.

#duration #convexity #bonds #yield curve #fixed income