Calculating the yield to maturity

The yield to maturity (YTM) measures the interest rate, as implied by the bond, that takes into account the present value of all the future coupon payments and the principal. It is assumed that bond holders can invest received coupons at the YTM rate until the maturity of the bond; according to risk-neutral expectations, the payments received should be the same as the price paid for the bond.

Let's take a look at an example of a 5.75 percent bond that will mature in 1.5 years with a par value of 100. The price of the bond is $95.0428 and coupons are paid semi-annually. The pricing equation can be stated as follows:

Calculating the yield to maturity

Here, Calculating the yield to maturity is the coupon dollar amount paid at each time period, Calculating the yield to maturity is the time period of payment in years, Calculating the yield to maturity is the coupon payment frequency, and Calculating the yield to maturity is the YTM that we are interested to solve. To solve for YTM is typically a complex process, and most bond YTM calculators use Newton's method as an iterative process.

The bond YTM calculator is illustrated by the following Python code. Save this file as bond_ytm.py:

""" Get yield-to-maturity of a bond """
import scipy.optimize as optimize


def bond_ytm(price, par, T, coup, freq=2, guess=0.05):
    freq = float(freq)
    periods = T*freq
    coupon = coup/100.*par/freq
    dt = [(i+1)/freq for i in range(int(periods))]
    ytm_func = lambda(y): 
        sum([coupon/(1+y/freq)**(freq*t) for t in dt]) + 
        par/(1+y/freq)**(freq*t) - price
        
    return optimize.newton(ytm_func, guess)

Remember that we covered the use of Newton's method and other nonlinear function root solvers in Chapter 3, Nonlinearity in Finance. For this YTM calculator function, we used the scipy.optimize package to solve for the YTM.

Using the parameters from the bond example, we get the following result:

>>> from bond_ytm import bond_ytm
>>> ytm = bond_ytm(95.0428, 100, 1.5, 5.75, 2)
>>> print ytm
0.0936915534524

The YTM of the bond is 9.369 percent. Now we have a bond YTM calculator that can help us compare a bond's expected return with those of other securities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.163.175