始める無料で始める

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.

この演習はコースの一部です

Bond Valuation and Analysis in R

コースを見る

演習の手順

  • 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.

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Calculate bond price when yield increases
px_up <- bondprc(p = ___, r = ___, ttm = ___, y = ___)

# Calculate bond price when yield decreases
px_down <-

# Calculate duration
duration <- (___ - ___) / (2 * ___* ___)

# Calculate percentage effect of duration on price
duration_pct_change <-
duration_pct_change

# Calculate dollar effect of duration on price
duration_dollar_change <-
duration_dollar_change
コードを編集して実行