Bond Risk Measures and Immunization › Convexity

Michael BrenndoerferNovember 8, 20258 min read
Quantitative FinanceAll chapters
Part 2 of 15Equity and Fixed Income Markets
Chapter 13Bond Risk Measures and Immunization › Convexity
Reading section 5 of 13 · Convexity · 8 minSection 5 of 13 · 8 min

Book contents

Section 5 of 13 · 8 min read

Bond Risk Measures and Immunization › ConvexityOne section · Sections in this chapter5 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Convexity

Convexity is the second derivative of price with respect to yield, divided by price. It provides a second-order correction to the duration estimate; it is not simply the derivative of modified duration.

Duration provides a first-order approximation to price changes, analogous to using the slope of a curve to estimate nearby points. However, the price-yield relationship is not a straight line but a curve that bends upward. Convexity measures this curvature and allows us to improve our price estimates significantly.

The first derivative describes the slope of the price-yield curve; the second derivative describes how that slope changes. Modified duration is the negative first derivative divided by price, while convexity is the second derivative divided by price. Consequently, dDMod/dy=DMod2−CdD_{Mod}/dy=D_{Mod}^2-C, rather than simply CC.

Convexity is derived from the second derivative of the price function with respect to yield. Starting from the first derivative:

dPdy=−∑t=1nt⋅Ct(1+y)t+1\frac{dP}{dy} = -\sum_{t=1}^{n} \frac{t \cdot C_t}{(1+y)^{t+1}}

Taking the derivative again,

d2Pdy2=−∑t=1nt⋅Ct⋅ddy(1+y)−(t+1)(apply chain rule)=−∑t=1nt⋅Ct⋅(−(t+1))(1+y)−(t+2)(power rule)=∑t=1nt(t+1)⋅Ct(1+y)t+2(simplify)\begin{aligned} \frac{d^2P}{dy^2} &= -\sum_{t=1}^{n} t \cdot C_t \cdot \frac{d}{dy}(1+y)^{-(t+1)} && \text{(apply chain rule)} \\ &= -\sum_{t=1}^{n} t \cdot C_t \cdot (-(t+1))(1+y)^{-(t+2)} && \text{(power rule)} \\ &= \sum_{t=1}^{n} \frac{t(t+1) \cdot C_t}{(1+y)^{t+2}} && \text{(simplify)} \end{aligned}

With nonnegative cash flows and a positive discount base, the second-derivative terms are nonnegative; at least the principal term is positive. Thus the fixed-cash-flow price-yield curve is convex: its slope becomes less negative as yield increases.

Dividing by price to get the convexity measure,

C=1Pd2Pdy2=1P∑t=1nt(t+1)⋅Ct(1+y)t+2C = \frac{1}{P}\frac{d^2P}{dy^2} = \frac{1}{P}\sum_{t=1}^{n} \frac{t(t+1) \cdot C_t}{(1+y)^{t+2}}

where:

  • CC: convexity
  • PP: bond price
  • tt: time period
  • CtC_t: cash flow at time tt
  • yy: yield to maturity
  • nn: total number of periods

For semi-annual compounding, the formula adjusts to:

C=1P∑t=1nt(t+1)⋅Ct(1+y/2)t+2⋅14C = \frac{1}{P}\sum_{t=1}^{n} \frac{t(t+1) \cdot C_t}{(1+y/2)^{t+2}} \cdot \frac{1}{4}

where the factor of 1/41/4 (equivalently 1/k21/k^2 for frequency kk) arises from converting the period-based calculation to annual terms. This adjustment accounts for the fact that both the time units and the yield compounding are expressed in periods rather than years. Without this adjustment, the convexity value would be scaled incorrectly when used in the price approximation formula with yield changes expressed in annual terms.

In[13]:
Code
def convexity(face_value, coupon_rate, years_to_maturity, yield_rate, frequency=2):
    """Calculate convexity of a bond."""
    periods, coupon_payment, periodic_yield = _bond_terms(
        face_value, coupon_rate, years_to_maturity, yield_rate, frequency
    )

    price = bond_price(
        face_value, coupon_rate, years_to_maturity, yield_rate, frequency
    )

    conv_sum = 0
    for t in range(1, periods + 1):
        if t < periods:
            cf = coupon_payment
        else:
            cf = coupon_payment + face_value

        pv_cf = cf / (1 + periodic_yield) ** (t + 2)
        conv_sum += t * (t + 1) * pv_cf

    # Adjust for frequency
    return conv_sum / (price * frequency**2)
In[14]:
Code
conv = convexity(face_value, coupon_rate, maturity, yield_rate)
print("Bond: 10-year, 5% coupon at 5% yield")
print(f"Convexity: {conv:.4f}")
Out[14]:
Console
Bond: 10-year, 5% coupon at 5% yield
Convexity: 73.6287

Duration-Convexity Approximation

With both duration and convexity, we can form a second-order Taylor expansion for price changes. The Taylor series provides a systematic way to approximate a function near a point using its derivatives. By including the second derivative (convexity), we capture the curvature that the first-order approximation using duration alone misses.

The Taylor series expansion of price around the current yield y0y_0 is

P(y0+Δy)≈P(y0)+dPdyΔy+12d2Pdy2(Δy)2P(y_0 + \Delta y) \approx P(y_0) + \frac{dP}{dy}\Delta y + \frac{1}{2}\frac{d^2P}{dy^2}(\Delta y)^2

Dividing by PP and substituting our definitions of duration and convexity,

ΔPP≈−DMod⋅Δy+12⋅C⋅(Δy)2\frac{\Delta P}{P} \approx -D_{Mod} \cdot \Delta y + \frac{1}{2} \cdot C \cdot (\Delta y)^2

where:

  • ΔP/P\Delta P / P: the percentage change in bond price
  • DModD_{Mod}: modified duration (first-order sensitivity)
  • CC: convexity (second-order sensitivity)
  • Δy\Delta y: change in yield (as a decimal)

For positive convexity, the second-order term is nonnegative because (Δy)2≥0(\Delta y)^2\geq0. It is positive for a nonzero yield change and zero at the expansion point. Fixed nonnegative cash flows with positive discount bases have positive convexity under the yield convention used here; embedded options can change that conclusion.

Intuitively, this reflects the asymmetric benefit of convexity. Bondholders gain more from falling rates than they lose from rising rates of the same magnitude. This asymmetry arises because the price-yield curve bends upward, being convex to the origin. Any movement away from the current yield produces a price that lies above the tangent line approximation. The convexity term approximates this difference to second order; higher-order terms remain.

In[15]:
Code
# Compare approximations
print("Comparison: Duration Only vs. Duration + Convexity")
print("=" * 80)
print(
    f"{'Yield Change':>12} {'Actual':>12} {'Dur Only':>12} {'Dur+Conv':>12} {'Dur Err':>10} {'D+C Err':>10}"
)
print("-" * 80)

for dy in yield_changes:
    new_yield = yield_rate + dy
    actual_price = bond_price(face_value, coupon_rate, maturity, new_yield)

    # Duration-only approximation
    dur_approx = price * (1 - mod_dur * dy)

    # Duration + convexity approximation
    dur_conv_approx = price * (1 - mod_dur * dy + 0.5 * conv * dy**2)

    dur_error = (dur_approx - actual_price) / actual_price * 100
    dc_error = (dur_conv_approx - actual_price) / actual_price * 100

    print(
        f"{dy * 100:>+12.1f}% {actual_price:>12.2f} {dur_approx:>12.2f} {dur_conv_approx:>12.2f} {dur_error:>+10.3f}% {dc_error:>+10.3f}%"
    )
Out[15]:
Console
Comparison: Duration Only vs. Duration + Convexity
================================================================================
Yield Change       Actual     Dur Only     Dur+Conv    Dur Err    D+C Err
--------------------------------------------------------------------------------
        -2.0%      1171.69      1155.89      1170.62     -1.348%     -0.091%
        -1.0%      1081.76      1077.95      1081.63     -0.352%     -0.012%
        -0.5%      1039.91      1038.97      1039.89     -0.090%     -0.002%
        +0.5%       961.93       961.03       961.95     -0.094%     +0.002%
        +1.0%       925.61       922.05       925.74     -0.384%     +0.013%
        +2.0%       857.88       844.11       858.83     -1.605%     +0.112%

Adding convexity dramatically improves the approximation. The duration-convexity model captures nearly all price movements even for substantial yield changes of 200 basis points. The remaining small errors arise from higher-order terms in the Taylor expansion that we have not included.

Visualizing Duration and Convexity

Out[16]:
Visualization
Three curves showing actual price, linear duration approximation, and quadratic duration-convexity approximation.
Comparison of price approximation methods for a 10-year, 5% coupon bond centered at 5% yield. The actual price curve (blue solid line) shows the true bond prices across yields from 2% to 8%. The duration-only approximation (red dashed line) is tangent to the actual curve at the current yield but diverges materially at distant yields, underestimating prices in both directions. Adding the convexity term (green dashed-dotted curve) produces a parabolic approximation that closely tracks the actual price across the entire yield range, showing the practical value of including second-order effects for accurate price estimation.

The visualization shows the duration approximation as a tangent line that diverges from the actual curve as we move away from the current yield. The straight red dashed line represents what duration alone predicts, touching the actual curve only at the current yield of 5%. The duration-convexity approximation, being a parabola (a quadratic function), tracks the actual curve much more closely across the entire yield range. The green dashed-dotted curve hugs the blue actual price curve, showing the value of including the second-order term.

Out[17]:
Visualization
Line chart showing convexity increasing with maturity for different coupon rates.
Convexity as a function of maturity for bonds with different coupon rates at 5% yield, showing convexity values from 1 to 30 years maturity. The zero-coupon curve grows approximately with the square of maturity. In these coupon-bond examples, convexity also rises with maturity but more slowly, because coupon payments distribute present-value weight before maturity; all four 30-year values exceed 200. Zero-coupon bonds exhibit the highest convexity at each maturity because concentrating all cash flow at a single point maximizes the curvature of the price-yield relationship. Higher coupon rates reduce convexity at each maturity level, with the 8% coupon bond showing the lowest convexity values.