Yield to Maturity (YTM) – A Comprehensive Guide
What is Yield to Maturity (YTM)?
Yield to Maturity (YTM) is the total return an investor can expect to earn if the bond is held until maturity. It accounts for the bond’s current market price, coupon payments, and face value repaid at maturity.
Formula for Yield to Maturity
The formula for calculating YTM is based on the present value of a bond’s future cash flows. It is expressed as:
Where:
- P = Current price of the bond
- C = Coupon payment per period
- F = Face value of the bond (par value)
- YTM = Yield to Maturity (annualized)
- n = Number of periods (years)
- t = Time period (number of periods)
How to Calculate YTM
The YTM is typically found using a numerical method (like the Newton-Raphson method) as it involves solving for an unknown in the bond price equation. Here’s an example of how to calculate YTM programmatically using Python:
Python Code to Calculate YTM:
import numpy as np
from scipy.optimize import fsolve
def bond_price(ytm, coupon_rate, face_value, periods, price):
return sum([coupon_rate * face_value / (1 + ytm)**t for t in range(1, periods+1)]) + face_value / (1 + ytm)**periods - price
def calculate_ytm(price, coupon_rate, face_value, periods):
ytm = fsolve(bond_price, 0.05, args=(coupon_rate, face_value, periods, price))
return ytm[0] * 100 # Convert to percentage
# Example Inputs
price = 950 # Current bond price
coupon_rate = 0.08 # 8% annual coupon
face_value = 1000 # Face value
periods = 10 # Bond maturity period in years
ytm = calculate_ytm(price, coupon_rate, face_value, periods)
print(f"The Yield to Maturity (YTM) is: {ytm:.2f}%")
Understanding the Code
The Python code above uses the fsolve
function from the scipy.optimize
library to find the YTM that satisfies the bond price equation. The code calculates the YTM for a bond with the following parameters:
- Bond price: 950
- Coupon rate: 8% annual coupon
- Face value: 1000
- Bond maturity period: 10 years
The output of the code will display the YTM in percentage form.
Download YTM Guide PDF Go to YTM Calculator