Exercise

Predicted vs. actual prices I

Plotting the predicted prices of bonds for different levels of yields using duration, then comparing these predicted prices to the actual prices of the bond is a great way of visualizing the accuracy of duration.

In this exercise, you will begin by finding the duration of the bond, as well as the price of the bond at different yield levels. In the next exercise, you will find the predicted price from duration and plot the difference.

The bond you will consider is a 10 year bond paying an annual coupon of 5% and a yield to maturity of 5%.

numpy, numpy_financial, pandas, and matplotlib have already been imported for you as np, npf, pd, and plt, respectively.

Instructions

100 XP
  • Find the duration and dollar duration of the bond.
  • Create an array of bond yields from 0 to 10 in increments of 0.1 and convert this array to a pandas DataFrame called bond_yield.
  • Add the column price containing the bond price for each level of yield.