When interested in buying bonds a term that often comes up is the definition of Yield To Maturity (YTM).

Yield to maturity (YTM) is the total return anticipated on a bond if the bond is held until the end of its lifetime. Yield to maturity is considered a long-term bond yield, but is expressed as an annual rate. In other words, it is the internal rate of return of an investment in a bond if the investor holds the bond until maturity and if all payments are made as scheduled. – Investopedia

Let us consider a bond with a par value of and a coupon rate of with the bond maturing in years time. The current bond price is . We are interested in the bond’s YTM.

Knowing that we get annual cashflow () we will have the following cashflow for the next years. Notice in the last year we will receive an additional which is the bond’s principle:

Let us assume that we want to value these future cashflows and determine how much they are worth today. What we need to do, is to present value all of these future cashflows back to today and add up those present values . This sum would be the price of the bond.

A present value is the amount of money one would need to invest today in order to have amount of money in years if he is earning annual interest on his investment:

For example, if Bob wants to have one year from now at a rate of , he needs to invest today (), since .

Back to our bond’s present value of future cashflows the resulting formula would look as follows:

with being the yield to maturity we are looking for.

For our particular bond the formula will look like this:

So how can we go about finding ? Well, above we have learned that sum of present values of all future cash flows is our bond price. Since we already know the today’s bond price which is , the formula becomes like this:

All we need to do now is to solve the above equation for so that it holds true. We will do this through trial-and-error.

Solving the equation by hand requires an understanding of the relationship between a bond’s price and its yield, as well as of the different types of bond pricings. Bonds can be priced at a discount, at par and at a premium. When the bond is priced at par, the bond’s interest rate is equal to its coupon rate. A bond priced above par (called a premium bond) has a coupon rate higher than the interest rate, and a bond priced below par (called a discount bond) has a coupon rate lower than the interest rate. So if an investor were calculating YTM on a bond priced below par, he or she would solve the equation by plugging in various annual interest rates that were higher than the coupon rate until finding a bond price close to the price of the bond in question (_quote from:_ Investopedia).

You can verify this quickly with a simple example. Assume a bond with current price and a par value of that matures in year. The coupon rate is and interest rate is :

==>

==>

If then . Similarly for the other cases.

Back to our bond. We had the following equation:

Now we must solve for the interest rate which is where things start to get difficult. Yet, we do not have to start simply guessing random numbers if we stop for a moment to consider the relationship between bond price and yield. As was mentioned above, when a bond is priced at a discount from par, its interest rate will be greater than the coupon rate. In this example, the par value of the bond is , but it is priced below the par value at , meaning that the bond is priced at a discount. As such, the annual interest rate we are seeking must necessarily be greater than the coupon rate of .

With this information we can now calculate and test a number of bond prices by plugging various annual interest rates that are higher than into the formula above. Using a few different interest rates above , one would come up with the following bond prices:

1 2 3 4 5 6 |
... ytm:3.61% price: 89.06 ytm:3.61% price: 89.04 ytm:3.61% price: 89.02 ytm:3.62% price: 89.01 ytm:3.62% price: 88.99 |

I have used increments and as we can see with an interest rate of we can approximate our current price of quite good enough. So would be our Yield To Maturity.

1 |
$ python3 yield.py -p 139.87 -f 99.94 -r 6.250 -y 12 -s |

**Full code**

**Result:**

1 2 3 4 5 6 7 8 9 10 |
------------------------------------------------ Price: 139.87 Face Value: 99.94 Annual coupon rate: 6.25% Coupon: 6.24625 Semi-annual coupon: True Years remaining: 12 Yield to Maturity: 2.40% |