Free lesson · Rates, credit & macro
Duration, convexity, and curve hedges
Open interactive lessonPractice calculationsExplore labs
Start with the idea
Duration and convexity approximate the slope and curvature of a bond’s price-yield relationship. They make a large cash-flow schedule easier to reason about locally, but a single parallel-yield sensitivity cannot capture every curve move.
Symbols, units & horizon
- P: current currency price or book value as specified
- y: decimal annual effective yield
- ∂: derivative with other inputs fixed
- D_mod: modified duration in years
- C: convexity, not coupon here, in years squared under this convention
- Δy: absolute decimal yield change
- ΔP/P: fractional price change
- DV01: positive magnitude of price decline for a 1 bp yield rise for an ordinary long bond
- 10⁻⁴: one basis point as a decimal
- N_hedge: signed hedge contract count
- CFₜ: currency cash flow at year t
When and why to use this
Use DV01 to compare and hedge rate risk across positions. Add key-rate, spread and optionality scenarios when those are material.
Differentiate discounted cash flows
- For , differentiate to get .
- Differentiate again: . Divide −P′ and P″ by price for modified duration and convexity.
For a one-year zero-coupon bond, Dmod=1/(1+y) and convexity=2/(1+y)². At 5% they are .952381 and 1.814059.
Use Taylor expansion and convert a basis point
- . Divide by P and substitute duration and convexity.
- For a one-basis-point rise, Δy=.0001. The magnitude of the first-order dollar loss is . The sign of a long conventional bond’s price change is negative.
A $2m position, D=6,C=45,Δy=.005 has approximate return −.03+.0005625=−2.94375%; DV01=$1,200.
Duration is the first-order sensitivity to a yield move and convexity is the second-order correction. DV01 is the positive magnitude of a small loss from a one-basis-point yield increase for a conventional long bond. Use position value for dollar risk; use yield changes as decimals.
A single duration assumes a parallel shift. Key-rate durations separate sensitivities to curve tenors, exposing steepener and butterfly risks. Equal total DV01 can hide a long two-year/short thirty-year mismatch. Optionality and changing spreads can make a fixed-duration approximation unreliable.
Solve a first-order hedge equation
- Require signed book sensitivity plus N times one contract’s sensitivity to equal zero: .
- Subtract the book sensitivity and divide by contract sensitivity. Round to executable contract counts, then recalculate the remaining exposure.
Book DV01=$1,200, hedge contract=$80 per bp → N=−15. The short hedge offsets only the chosen first-order risk.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
def bond_sensitivities(cashflows, yield_rate):
"""Annual periods at t=1,...; final cash flow includes principal."""
if yield_rate <= -1:
raise ValueError("Yield must exceed -1")
p = sum(cf/(1+yield_rate)**t for t,cf in enumerate(cashflows,1))
first = -sum(t*cf/(1+yield_rate)**(t+1) for t,cf in enumerate(cashflows,1))
second = sum(t*(t+1)*cf/(1+yield_rate)**(t+2) for t,cf in enumerate(cashflows,1))
duration, convexity = -first/p, second/p
return p, duration, convexity, p*duration*1e-4
def duration_pnl(price, duration, convexity, yield_change):
return price*(-duration*yield_change+.5*convexity*yield_change**2)
def hedge_contracts(book_dv01, one_contract_dv01):
return -book_dv01/one_contract_dv01 # round subject to residual risk
print(bond_sensitivities([5,105], .05))Continue learning
Rates, Credit & Macro — all lessons- Price a bond from its cash flows
- Duration, convexity, and curve hedges
- Credit spreads compensate more than expected default
- Carry, forward prices, and macro surprises
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations