# How to calculate YTM of AmortizingFixedRateBond in QuantLib - Python?

I'm trying to calculate the ytm of bonds amortized in quantlib. The maturity of this bond is five years, starting from the second year to repay 25% of the face value until the last year.

The cash flow of bonds is correct. I want to calculate ytm based on the current net price, but I don't know why it is wrong.

I have the following bond:

Maturity Date:
24.07.2024
Coupon Frequency:
25 at 24.07.2021
25 at 24.07.2022
25 at 24.07.2023
25 at 24.07.2024
Day Count
Convention: ACT/365
Coupon rate: 6.5


Here is the python code

start_d = ql.Date(24, ql.July, 2019)
mat_d = ql.Date(24, ql.July, 2024)
calc_date = ql.Date(8, ql.December, 2022)
frequency = ql.Period(ql.Annual)
freq = ql.Annual
dayCounter = ql.Actual365Fixed()

cleanprice = 45.83
ql.Settings.instance().evaluationDate = calc_date

schedule = ql.MakeSchedule(start_d, mat_d, frequency)

bond = ql.AmortizingFixedRateBond(0, [100, 100, 75, 50, 25, 0], schedule, [0.065], dayCounter)
for c in bond.cashflows():
print(f"{str(c.date()):20} => {c.amount():.4}")

ytm = bond.bondYield(float(cleanprice), dayCounter, ql.Compounded, freq)
print(f"{'YTM':20} => {round(ytm * 100, 8):.6}")
print(f"{'Accrued days':20} => {str(ql.BondFunctions.accruedDays(bond)):.4}")
print(f"{'Accrued amount':20} => {round(bond.accruedAmount(), 8):.4}")


The following is the printing of cash flow and ytm

July 24th, 2020      => 6.518
July 24th, 2021      => 6.5
July 24th, 2021      => 25.0
July 24th, 2022      => 4.875
July 24th, 2022      => 25.0
July 24th, 2023      => 3.25
July 24th, 2023      => 25.0
July 24th, 2024      => 1.629
July 24th, 2024      => 25.0
YTM                  => 125.49
Accrued days         => 138
Accrued amount       => 2.458

• In most bond markets, the convention for quoting the clean price of amortizing bonds is to apply the current factor. 45.83 is a very distressed price. Try dividing this price by the percentage of remaining notional, because that's how it would usually be quoted in the market. Dec 8, 2022 at 12:51
• What yield do you expect to see and why? Dec 8, 2022 at 14:03
• From the perspective of cash flow, the principal of this bond has been repaid by 50 yuan. In theory, there is still 50 yuan of face value left on my calculation date, so the price of 45.83 is reasonable. Dec 9, 2022 at 3:25
• Please see below that I output the current interest accrual days and accrued interest. Theoretically, the interest accrual days are 138 days, and the current bond face value is 50. Therefore, the accrued interest should be 138/365 * 6.5/2=1.2287, and the output result is 2.458. Dec 9, 2022 at 3:34
• In addition, I divide this price by the percentage of the remaining nominal price as you said, that is, 45.83/50/100=91.66. It is correct to use this price to calculate the yield, and the result is 15.1357%. So I guess that although the output cash flow is 25% of the principal paid in each period, the bond does not reduce the corresponding face value according to the cash flow when calculating the yield? Dec 9, 2022 at 3:40