# Fixed rate bond pricing issue in Quantlib

I cannot retrieve the same price for a fixed bond using quantlib.

faceValue = 100.
couponType = ql.Semiannual
issueDate = ql.Date(19, 4, 2019)
EvalDate = ql.Date(24, 5, 2019)
Maturity = ql.Date(19, 4, 2022)
quotedYield = 3.69
couponRate = 3.84
calendar = ql.NullCalendar()
settlementDays = 0
Datesgeneration = ql.DateGeneration.Forward
period= ql.Period(ql.Semiannual)
monthEnd = False

B1 = Bond(faceValue, couponType, EvalDate, issueDate, Maturity, quotedYield, couponRate, calendar)

ql.Settings.instance().evaluationDate = EvalDate

bond = ql.FixedRateBond(settlementDays, faceValue, schedule, [couponRate/100.], ql.ActualActual(ql.ActualActual.ISMA))

print("QuantLib: ", bond.dirtyPrice(quotedYield/100., ql.ActualActual(ql.ActualActual.ISMA), ql.Simple, ql.Semiannual))


I should have got 100.774 when rounded to 3 decimals but i got 100.771. 100.774 is similar to Bloomberg pricer or excel using the classical discounted cashflow method to compute the price.

Can you help me?

Thanks Is there something wrong ?

Well, you are fetching the dirty price by discounting the cashflows with a simple rate instead of compounded rate which is not really the most common way. Not sure if this is what you want.

You are essentially using the discount factors as:

$$DF_i = \frac{1}{(1+r_i * n)}$$

$$DF_i = \frac{1}{(1+r_i)^n}$$
print("QuantLib: ", bond.dirtyPrice(quotedYield/100., ql.ActualActual(ql.ActualActual.ISMA), ql.Compounded, ql.Semiannual))