Bond Valuation and Analysis in Python
Joshua Mayhew
Options Trader
-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
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
We will use a simplified formula for duration:
${\large Duration = \frac{P_{down}\ -\ P_{up} }{2\ \times\ P\ \times\ \Delta y}}$
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