Discussion about this post

User's avatar
Jim's avatar

Hi Luigi,

In this chapter you mentioend that "This is because the bond methods don’t rely on the reference date of the curve (which doesn’t always equal the evaluation date) but on the global evaluation date." but when I realize the bond by code like below. It seems the bond method relay on the "today" I passed it to since I will get a different value when the today is different with reference day.

bond = ql.FixedRateBond(0, face_amount, schedule, coupon, day_count)

bond_price = 102.0 + 7/32

bond_yield = bond.bondYield(bond_price, day_count,

ql.Compounded, ql.Semiannual, today)

calculated_clean_price = bond.cleanPrice(bond_yield, day_count,

ql.Compounded, ql.Semiannual, today)

dirty_price = bond.dirtyPrice(bond_yield, day_count,

ql.Compounded, ql.Semiannual, today)

accrued_interest = bond.accruedAmount(today)

However, I passed the "today" to the flatforward curve as well.

flat_curve = ql.FlatForward(today, ql.QuoteHandle(ql.SimpleQuote(bond_yield)),

ql.ActualActual(ql.ActualActual.ISDA), ql.Compounded, ql.Semiannual)

discount_curve_handle = ql.YieldTermStructureHandle(flat_curve)

bond.setPricingEngine(ql.DiscountingBondEngine(discount_curve_handle))

print(bond.cleanPrice())

print(bond.accruedAmount(today))

print(bond.dirtyPrice())

I found even i use today as parameter to calculte the accured interest, it still use the refference date.

is this a bug or somehow you made it on purpose? Thanks!

Expand full comment
1 more comment...

No posts