SigmaField

Practice Fixed income

Solve yields for a bond ladder

Easy+10 pointsAbout 25 minutesFixed income

The brief

A pension fund holds a bond ladder: $2 million of face value in a bond maturing in each of the next five years. As each bond repays, the fund reinvests the cash at the long end.

The quarterly report needs each bond's yield to maturity and one yield for the whole ladder. The trustees ask for the second, and the plain average of the five yields is not it.

Your task

  1. Write bond_price(coupon_rate, years, y): the price per $100 of face value of a bond paying 100 * coupon_rate once a year for years years, and $100 at the end, at the yearly yield y. It must work at y = 0.
  2. Write ytm(price, coupon_rate, years): the yield at which bond_price equals price. Yields can be negative. Raise ValueError for a price of zero or below: no yield can produce it.
  3. Write ladder_yield(ladder): the one yearly yield that discounts all the ladder's cash flows, in dollars, to its market value. Raise ValueError for an empty ladder, or for a bond with a price or face value of zero or below.

The data

LADDER in the code lists the five bonds. Each has a maturity in years, a coupon_rate as a decimal and a price per $100 of face value. Its face is the dollar amount the fund holds.

Every bond pays its coupon once a year, and today is a coupon date.

Hint: Price, then yield

Case study 1.5.5 prices a bond as an annuity of coupons plus the discounted face value. It needs a separate branch for a zero yield. Case study 1.3.5 turns a price into a yield with brentq, from a bracket that starts at −0.99-0.99.

Hint: One yield for the ladder

Add up the ladder's cash flows year by year, in dollars. Its yield is the internal rate of return of paying the market value today and receiving those flows (case study 1.3.5).

Hint: Why not the average?

The plain average gives each bond the same say. But a change in yield moves a long bond's price further than a short one's (case study 1.5.5). So the long bonds, which yield more here, count for more in the ladder's yield.