YTM refers to the internal rate of return calculated at the market price if you hold a bond to maturity and the principal and interest of the bond are paid as scheduled. If discounting the bond at YTM, the present value of all its future cash flows (including those of principal and interest) will be equal to the purchase price.
Generally, you can refer to the following formula:
Where:
Y: yield to maturity
PV: bond market price
M: par value
t: remaining years to maturity
I: coupon rate
If a bond with a par value of 100 has a market price of 95, pays interest at an annual interest rate of 6% and matures in 2 years, then
Its YTM is around 8.78%