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.
Diese Übung ist Teil des Kurses
Bond Valuation and Analysis in R
Anleitung zur Übung
- Use
bondprc()
to calculate the price of the bond when yields increase by 1%. Save this topx_up
. - Use
bondprc()
to calculate the price of the bond when yields decrease by 1%. Save this topx_down
. - Use
px
,px_up
, andpx_down
to calculateduration
with the formula above. - Calculate and view the percentage effect of duration on price (
duration_pct_change
) based onduration
. - Calculate and view the dollar effect of duration on price (
duration_dollar_change
) based on duration.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# 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