ComeçarComece de graça

Comparing the duration of two bonds directly

A quick way to check the impact of a factor on duration is to find the duration of two different bonds where you increase this factor and see what effect it has on the bond's duration.

In this exercise, you will calculate the duration of a 10 year and a 20 year bond, both paying an annual coupon of 3%, with a face value of USD 100, and yield to maturity of 5%.

numpy_financial is already imported for you as npf.

Este exercício faz parte do curso

Bond Valuation and Analysis in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Find & print duration of 10 year bond with 3% coupon & 5% yield
price_10y = -npf.pv(rate=0.05, nper=____, pmt=____, fv=____)
price_up_10y = -npf.pv(rate=0.06, nper=____, pmt=____, fv=____)
price_down_10y = -npf.pv(rate=0.04, nper=____, pmt=____, fv=____)
duration_10y = (____ - ____) / (____ * ____ * ____)
print("10 Year Bond: ", ____)
Editar e executar o código