直接比较两只债券的凸性
您还可以通过仅改变某一因素来定价两只债券,并分别计算其凸性,从而研究该因素对债券凸性的影响。
在本练习中,您将计算两只债券的凸性。两只债券的期限均为 5 年,收益率为 3%,面值为 USD 100。不同之处在于:第一只债券的年票息为 1%,第二只债券的年票息为 10%。
numpy_financial 已为您导入为 npf。
本练习是课程的一部分
用 Python 进行债券定价与分析
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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: ", ____)