Bond Risk Measures and Immunization › Convexity
Quantitative FinanceAll chapters 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 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, , rather than simply .
Convexity is derived from the second derivative of the price function with respect to yield. Starting from the first derivative:
Taking the derivative again,
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,
where:
- : convexity
- : bond price
- : time period
- : cash flow at time
- : yield to maturity
- : total number of periods
For semi-annual compounding, the formula adjusts to:
where the factor of (equivalently for frequency ) 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.
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)conv = convexity(face_value, coupon_rate, maturity, yield_rate)
print("Bond: 10-year, 5% coupon at 5% yield")
print(f"Convexity: {conv:.4f}")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 is
Dividing by and substituting our definitions of duration and convexity,
where:
- : the percentage change in bond price
- : modified duration (first-order sensitivity)
- : convexity (second-order sensitivity)
- : change in yield (as a decimal)
For positive convexity, the second-order term is nonnegative because . 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.
# 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}%"
)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

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.
