Calculating bond yields

Bond Valuation and Analysis in Python

Joshua Mayhew

Options Trader

Yield calculation motivation

  • Yield to maturity tells us our expected return on investment
  • Can be useful for comparing bonds with different characteristics
Bond Valuation and Analysis in Python

Zero coupon bond yield formula

Recall the formula for the price of a zero coupon bond:

$PV = \frac{FV}{(1 + r)^n}$

We can rearrange this equation to solve for yield $(r)$:

$FV = PV \times (1 + r)^n$

$ \frac{FV}{PV} = (1 + r)^n$

$ \sqrt[n]\frac{FV}{PV} = (1 + r)$

$ \sqrt[n]\frac{FV}{PV} -1 = r$

Bond Valuation and Analysis in Python

Zero coupon bond yield example

Let's look at the same zero coupon bond from earlier working backwards:

  • Has a 3 year maturity
  • A face value of USD 100
  • A price of USD 90.19

 

What is the yield of this bond?

Bond Valuation and Analysis in Python

Zero coupon bond yield calculation

3 year zero coupon bond, price USD 90.19, face value USD 100:

$r = \sqrt[n]\frac{FV}{PV} -1$

ytm = (100 / 90.19) ** (1/3) - 1
print(ytm)
0.035

 

We will use ytm for 'yield to maturity'.

Bond Valuation and Analysis in Python

Coupon bond yield formula?

Coupon bond formula:

$ PV = \frac{C}{(1 + r)^1} + \frac{C}{(1 + r)^2} + ... +\frac{C}{(1 + r)^n} + \frac{P}{(1 + r)^n}$

$ = \sum_{i=1}^n \frac{C}{(1 + r)^i} + \frac{P}{(1 + r)^n}$

This equation cannot be rearranged in terms of $r$

We use trial and error to find $r$

This is how the npf.rate() function works

Bond Valuation and Analysis in Python

Coupon bond yield example

Let's consider our coupon paying bond earlier which:

  • has a maturity of 3 years
  • pays a 3% annual coupon
  • has a price of USD 97.22

 

What is its yield to maturity?

Bond Valuation and Analysis in Python

Coupon bond yield calculation

3 year coupon bond, 3% annual coupon with a price of USD 97.22:

import numpy_financial as npf
npf.rate(nper=3, pmt=3, pv=-97.22, fv=100)
0.04

Remember we need to set the PV to a negative number.

This is because the price of the bond is money we pay (negative cash-flow).

Bond Valuation and Analysis in Python

Let's practice!

Bond Valuation and Analysis in Python

Preparing Video For Download...