# Bloomberg bond clean price and accrued amount differs from Quantlib

I'm getting the different bond clean price from Bloomberg and from QL but surprisingly Bloomberg price matches with excel price() function

I have the following bond : GETC21117030. The parameters are given below:

Parameter Name Value
Settlment Date 30-12-20
Bond Issue Date 17-Jan-19
Interest Acrual date 17-Jan-19
Maturity Date 17-Jan-21
Last Coupon Date 17-Jul-20
Coupon Rate 7.25%
Coupon Frequency 2
Day Count ACT/ACT
Redemption 100
Yield 7.95%
Calendar NullCalendar
GenRule Backward

if you look at the parameters you'll notice that there is only one payment left on maturity date. If I calculate price and accrued interest in QLXL I'm getting different results from Bloomberg. But surprisingly Bloomberg numbers match if I use excel native price calculation function.

I looked into the excel formula and it looks that the price calculate formula is different when there is only one payment left (see below)

When N > 1 (N is the number of coupons payable between the settlement date and redemption date), PRICE is calculated as follows: When N = 1 (N is the number of coupons payable between the settlement date and redemption date), PRICE is calculated as follows: DSR = number of days from settlement to next coupon date.

E = number of days in coupon period in which the settlement date falls.

A = number of days from beginning of coupon period to settlement date.

It seems that for the last payment calculation excel is moving from compounded yield to simple yield.

I calculated the clean price both with compounded yield and with simple yield. While the clean price with simple yield is close to the Bloomberg/Excel price it still does not match.

With 7.95% yield and settlement date 30 Dec 2020:

Bloomberg/Excel clean price is 99.953226, Accrued Amount 3.270380

QLXL(semiannually compounded yield) clean price is 99.95983172, Accrued Amount 3.288251366

QLXL(simple yield) clean price is 99.95278714, Accrued Amount 3.288251366

I'm not C++ specialist but the QL code I've checked does not change the price calculation algorithm when only one payment is left.

The question is: Is it possible with current implementation of QuantLib to match the price and accrued amount for the above mentioned bond (and in general with all coupon bonds when there is only one cashflow is left)?

Several things might be affecting your result. Check if all the conventions are correct, namely the daycount.

Regarding, the compounding on the last period, I can replicate Bloomberg's price for that bond in QuantLib using the SimpleThenCompounded parameter.

import QuantLib as ql

settlementDate = ql.Date(30,12,2020)
issueDate = ql.Date(17,1,2019)
maturityDate = ql.Date(17,1,2021)
coupon = 0.0725
freq = ql.Period('6M')
dayCount = ql.ActualActual(ql.ActualActual.ISMA)
yld = 0.0795

bbgPrice = 99.953226
bond = ql.FixedRateBond(0, ql.TARGET(), 100.0, issueDate, maturityDate, freq, [coupon], dayCount, ql.Unadjusted, ql.Unadjusted)
print(f"BBG Price: {bbgPrice}")

px = bond.cleanPrice(yld, dayCount, ql.SimpleThenCompounded, ql.Annual, settlementDate)
print(f"QuantLib  Price: {px:.6f}\n")


BBG Price: 99.953226
QuantLib Price: 99.953226