Duration is a sensitivity measure of bond prices to yield changes. Some duration measures are: effective duration, Macaulay duration, and modified duration. The type of duration that we will discuss is modified duration, which measures the percentage change in bond price with respect to a percentage change in yield (typically 1 percent or 100 basis points (bps)).
The higher the duration of a bond, the more sensitive it is to yield changes. Conversely, the lower the duration of a bond, the less sensitive it is to yield changes.
The modified duration of a bond can be thought of as the first derivative of the relationship between price and yield:
Here, dy is the given change in yield, is the price of the bond from a decrease in yield by dy, is the price of the bond from an increase in yield by dy, and is the initial price of the bond.
It should be noted that the duration describes the linear price-yield relationship for a small change in Y. Because the yield curve is not linear, using a large value of dy does not approximate the duration measure well.
The implementation of the modified duration calculator is given in the following Python code. The bond_mod_duration
function uses the bond_ytm
function as discussed earlier in this chapter to determine the yield of the bond with the given initial value. Also, it uses the bond_price
function to determine the price of the bond with the given change in yield:
""" Calculate modified duration of a bond """ from bond_ytm import bond_ytm from bond_price import bond_price def bond_mod_duration(price, par, T, coup, freq, dy=0.01): ytm = bond_ytm(price, par, T, coup, freq) ytm_minus = ytm - dy price_minus = bond_price(par, T, ytm_minus, coup, freq) ytm_plus = ytm + dy price_plus = bond_price(par, T, ytm_plus, coup, freq) mduration = (price_minus-price_plus)/(2*price*dy) return mduration
We can find out the modified duration of the 5.75 percent bond discussed earlier that will mature in 1.5 years with a par value of 100 and a bond price of 95.0428:
>>> from bond_mod_duration import bond_mod_duration >>> print bond_mod_duration(95.04, 100, 1.5, 5.75, 2, 0.01) 1.392
The modified duration of the bond is 1.392 years.