Trading Dev AcademyFree quant education

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.

Dmod=−1P∂P∂y,C=1P∂2P∂y2
Ordinary differentiation

Differentiate discounted cash flows

  1. For P(y)=∑CFt(1+y)−t, differentiate to get P′=−∑tCFt(1+y)−t−1.
  2. Differentiate again: P′′=∑t(t+1)CFt(1+y)−t−2. Divide −P′ and P″ by price for modified duration and convexity.
Work it by hand

For a one-year zero-coupon bond, Dmod=1/(1+y) and convexity=2/(1+y)². At 5% they are .952381 and 1.814059.

ΔPP≈−DmodΔy+12C(Δy)2,DV01≈PDmod10−4
Taylor approximation + unit conversion

Use Taylor expansion and convert a basis point

  1. ΔP≈P′Δy+P′′(Δy)22. Divide by P and substitute duration and convexity.
  2. For a one-basis-point rise, Δy=.0001. The magnitude of the first-order dollar loss is PDmod10−4. The sign of a long conventional bond’s price change is negative.
Work it by hand

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.

Nhedge≈−DV01bookDV01one hedge contract
Algebra and arithmetic

Solve a first-order hedge equation

  1. Require signed book sensitivity plus N times one contract’s sensitivity to equal zero: DV01book+NDV01contract=0.
  2. Subtract the book sensitivity and divide by contract sensitivity. Round to executable contract counts, then recalculate the remaining exposure.
Work it by hand

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
  1. Price a bond from its cash flows
  2. Duration, convexity, and curve hedges
  3. Credit spreads compensate more than expected default
  4. Carry, forward prices, and macro surprises

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations