Duration

Bond Valuation and Analysis in Python

Joshua Mayhew

Options Trader

The context behind duration

  • Prices and yields move inversely
  • We don't know how sensitive a bond is to interest rates
  • Duration measures interest rate sensitivity
Bond Valuation and Analysis in Python

Motivating example

  • Take a 5 year & 10 year bond, both with a 5% coupon
  • At a 5% yield they both have a price of USD 100:
-npf.pv(rate=0.05, nper=5, pmt=5, fv=100)
-npf.pv(rate=0.05, nper=10, pmt=5, fv=100)
100.00
100.00
Bond Valuation and Analysis in Python

Motivating example

If interest rates move up to 6%:

-npf.pv(rate=0.06, nper=5, pmt=5, fv=100)
-npf.pv(rate=0.06, nper=10, pmt=5, fv=100)
95.79
92.64
  • The 5 year bond lost 4.21% of its value, while the 10 year bond lost 7.36%

  • The 10 year bond was more sensitive to interest rate changes

Bond Valuation and Analysis in Python

What is duration?

  • Duration is the % price change for a 1% change in yields (interest rates).
  • Higher duration = higher interest rate risk
  • Typically used to:
    • Measure interest rate risk
    • Hedge interest rate risk
    • Predict profit & loss as interest rates change
Bond Valuation and Analysis in Python

Calculating duration

We will use a simplified formula for duration:

 

${\large Duration = \frac{P_{down}\ -\ P_{up} }{2\ \times\ P\ \times\ \Delta y}}$

 

  • $P_{down}$ = Bond price at 1% lower yield
  • $P_{up}$ = Bond price at 1% higher yield
  • $P$ = Bond price at current yield
  • $\Delta y$ = Change in yield (we will use 1%)
Bond Valuation and Analysis in Python

Duration example

10 year bond, 5% annual coupon, 4% yield to maturity, what is its duration?

${ Duration = \frac{P_{down}\ -\ P_{up} }{2\ \times\ P\ \times\ \Delta y}}$

price = -npf.pv(rate=0.05, nper=10, pmt=5, fv=100)

price_up = -npf.pv(rate=0.06, nper=10, pmt=5, fv=100) price_down = -npf.pv(rate=0.04, nper=10, pmt=5, fv=100)
duration = (price_down - price_up) / (2 * price * 0.01) print(duration)
7.74

A 1% move in interest rates causes a 7.74% change in the bond price.

Bond Valuation and Analysis in Python

Summary

  • Bonds can behave differently for the same change in yields
  • Duration is the % price change of a bond for a 1% change in yields
  • Duration measures interest rate sensitivity
Bond Valuation and Analysis in Python

Let's practice!

Bond Valuation and Analysis in Python

Preparing Video For Download...