Get startedGet started for free

Calculate convexity measure

Recall from Chapter Three that duration does not adequately adjust for the convex nature of the relationship between price and yield. To improve the estimate of the bond price based on duration, we can add a term based on the convexity measure.

In Chapter Three, you learned that the approximate formula for convexity is:

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

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

You have calculated the objects px, px_up, and px_down previously and all three objects are available in your workspace. For this exercise, assume the expected change in yield is 1%. Calculate the convexity measure, the estimated percentage change in price due to convexity, and the estimated dollar effect on price due to convexity.

This exercise is part of the course

Bond Valuation and Analysis in R

View Course

Exercise instructions

  • Use the formula above with px, px_up, and px_down to calculate convexity. Save this to convexity.
  • Use convexity and your knowledge about change in yield to calculate and view the percentage effect of convexity on price (convexity_pct_change).
  • Use convexity to calculate and view the dollar effect of convexity on price (convexity_dollar_change).

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Calculate convexity measure
convexity <-

# Calculate percentage effect of convexity on price
convexity_pct_change <-
convexity_pct_change

# Calculate dollar effect of convexity on price
convexity_dollar_change <-
convexity_dollar_change
Edit and Run Code