Session Ready
Exercise

Calculate duration

In Chapter Three, you learned to use the approximate duration formula. As a refresher, the formula for approximate duration is:

$$(P(down) - P(up)) / (2 * P * \Delta y)$$

where \(P\) is the price of the bond today, \(P(up)\) is the price of the bond if yields increase, \(P(down)\) is the price of the bond if yields decrease, and \(\Delta y\) is the expected change in yield.

In this exercise, you will calculate duration. Specifically, you'll use the bondprc() function to calculate px_up and px_down.

The objects px and aaa_yield from the prior exercises are preloaded in your workspace. For this exercise, assume that the expected change in yield is an increase of 1%. As before, the coupon rate is 3% (0.03) and the time to maturity 8 years.

Instructions
100 XP
  • Use bondprc() to calculate the price of the bond when yields increase by 1%. Save this to px_up.
  • Use bondprc() to calculate the price of the bond when yields decrease by 1%. Save this to px_down.
  • Use px, px_up, and px_down to calculate duration with the formula above.
  • Calculate and view the percentage effect of duration on price (duration_pct_change) based on duration.
  • Calculate and view the dollar effect of duration on price (duration_dollar_change) based on duration.