Comparing the convexity of two bonds directly
You can also investigate the influence of factors on bond convexity by pricing-up two bonds that vary only in this factor and then calculating the convexity of each bond directly.
In this exercise, you will find the convexity of two bonds; both will be 5 year bonds with a yield of 3% and face value of USD 100, but the first bond will pay a 1% coupon and the second bond will pay a 10% coupon.
numpy_financial
has already been imported for you as npf
.
This exercise is part of the course
Bond Valuation and Analysis in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Find the price of a 5 year bond with 3% yield and 1% coupon
price_1 = ____
# Shift yields up and down 1% and reprice
price_up_1 = ____
price_down_1 = ____
# Find convexity of the bond and print the result
convexity_1 = ____
print("Low Coupon Bond Convexity: ", ____)