2
$\begingroup$

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
businessConventions = ql.Following
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

schedule = ql.Schedule(issueDate, Maturity, period, calendar, businessConventions, businessConventions, Datesgeneration, monthEnd)

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 ?

$\endgroup$
1
$\begingroup$

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)}$$

instead of

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

If you change the last line to:

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

The output price will be 100.774

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.