Exercise - Yields#
Data#
Use the data file ../data/treasury_quotes_2025-04-30.xlsx.
1 YTM and Price#
The problems in this section ask you to calculate the yield-to-maturity (YTM) of various bonds.
You will need to use a nonlinear solver to solve for the YTM.
For any given bond, YTM (\(y\)) solves…
where
\(p\) is the bond’s price.
\(n\) is the number of years to maturity
\(c\) is the coupon rate (a percentage)
\(F\) is the face value. Use \(F=100\)
Solving for YTM#
Consider using fsolve to solve the yield implicitly from the nonlinear equation. This function is imported with…
from scipy.optimize import fsolve
1.1#
Consider a semiannual bond with the following stylized parameters:
time-to-maturity of 30 years
coupon rate: 3%
Face value of 100
Assume the YTM is 5%. Calculate the price.
Assume the price is 87. Calculate the YTM.
1.2#
Data#
Use the data in the selected quotes tab.
It gives treasury bond data for various maturities, spaced roughly six months apart.
Feel free to approximate the time-to-maturity to be exactly semiannually if that is easier for the problem below.
Use the
pricecolumn for the price data in the YTM formula. (No need to worry about “dirty” price, bid, ask, nor accrued interest.)
Calculate the yield-to-maturity for each issue. How close are your calculations to the provided column
ytm?Plot the time-to-maturity (TTM) against the calculated YTM.
2. Extra#
Try these problems if you are inclined. They are not required.
Data#
Use the data in the selected quotes tab.
Focus on the nominal securities.
Exclude any row with
typeofTIPS noteorTIPS bond.
2.1#
Plot the time-to-maturity against the provided YTM.
2.2#
Calculate the YTM of each (nominal) bond issue in the data set.
Report how far your YTM calculation is from those reported in the data set.
Report your calculated YTM for the issues where the dataset does not provide a YTM.
2.3#
For the Treasury bills, calculate the discount yields.
Identify the T-bills using type=bill or looking for cpnrate of 0.