Get startedGet started for free

Finding the convexity of a bond

Calculating the convexity of a bond is an important step in predicting bond price changes and measuring the interest rate risk of a portfolio in a more comprehensive way.

In this exercise, you are going to find the convexity of a 20 year bond that pays a 6% annual coupon, has a yield to maturity of 5%, and face value of USD 100.

Recall that the formula for convexity is given by:

\( Convexity = \frac{ P(down) \ + \ P(up) \ - \ 2 \times P }{P \ \times \ (\Delta y)^2} \)

numpy_financial has already been imported for you as npf.

This exercise is part of the course

Bond Valuation and Analysis in Python

View Course

Exercise instructions

  • Find the price of a 20 year bond with 6% coupon and 5% yield
  • Find the price of the same bond for a 1% higher and 1% lower level of yields.
  • Find the convexity of the bond and print the result.

Hands-on interactive exercise

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

# Find the price of a 20 year bond with 6% coupon and 5% yield
price = ____

# Find the price of the same bond for a 1% higher and 1% lower level of yields
price_up = ____
price_down = ____

# Find the convexity of the bond and print the result
convexity = ____
print("Convexity: ", ____)
Edit and Run Code