0
$\begingroup$

I am trying to use QuantLib Python to price a fixed rate bond, based on the following data:

Issue date is 28 September 2017 (issueDate), maturity date is 28 September 2024 (maturityDate), the bond is being valued as at 31 July 2020 (valuationDate), and coupons of 5% of face value of $1000 are payable on a semiannual basis (couponFrequency). However, the bond has been purchased on 05 May 2019 (transactionDate).

From my understanding, there should be no accrued interest as at the valuation date, since the bond has been purchased prior to the last coupon payment date before the valuation date, which is 28 March 2020.

However, QuantLib is still returning a figure for accrued interest, as if the bond has been purchased between the last coupon payment date before the valuation date and the valuation date.

Please see my codes below:

import QuantLib as ql

valuationDate = ql.Date(31, 7, 2020)
ql.Settings.instance().evaluationDate = valuationDate
compounding = ql.Compounded
calendar = ql.NullCalendar()
coupon = 0.05
couponFrequency = ql.Semiannual
issueDate = ql.Date(28, 9, 2017)
maturityDate = ql.Date(28, 9, 2024)
businessConvention = ql.Unadjusted

transactionDate = ql.Date(5, 5, 2019)
settlementDays = 0

schedule = ql.Schedule(issueDate, maturityDate, ql.Period(couponFrequency), calendar, businessConvention, businessConvention, ql.DateGeneration.Backward, True)
dayCount = ql.ActualActual(ql.ActualActual.ISMA, schedule)
faceValue = 100
redemptionValue = 100

fixedRateBond = ql.FixedRateBond(settlementDays, faceValue, schedule, [coupon], dayCount, businessConvention, redemptionValue)
curve = ql.ZeroCurve([ql.Date(31, 7, 2020), ql.Date(1, 1, 2027)], [0.01, 0.02], ql.ActualActual(), calendar, ql.Linear(), compounding, ql.Annual)
handle = ql.YieldTermStructureHandle(curve)
bondEngine = ql.DiscountingBondEngine(handle)
fixedRateBond.setPricingEngine(bondEngine)
print('Accrual start date:', ql.BondFunctions.accrualStartDate(fixedRateBond))
print('Accrual end date:', ql.BondFunctions.accrualStartDate(fixedRateBond))
print('Accrued days:', ql.BondFunctions.accruedDays(fixedRateBond))
print('Number of days between accrual start date and accrual end date:', ql.ActualActual().dayCount(ql.BondFunctions.accrualStartDate(fixedRateBond), ql.BondFunctions.accrualEndDate(fixedRateBond)))
print("QuantLib's accrued interest:", fixedRateBond.accruedAmount())

The results are as follows:

Accrual start date: March 28th, 2020

Accrual end date: March 28th, 2020

Accrued days: 125

Number of days between accrual start date and accrual end date: 184

QuantLib's accrued interest: 1.6983695652173836

I understand that the computation has been done by QuantLib using the following formula:

However, the accrued interest should be 0 since the transaction date is prior to 28 March 2020.

Is there a way to incorporate the transaction date in QuantLib's FixedRateBond engine, without using an if condition, to return an accrued interest of 0 in this case, relative to the valuation date?

Any help is most welcomed, thanks!

$\endgroup$
4
  • 2
    $\begingroup$ Why does the transaction date of the bond have anything to do with the accrued interest if it is in the past ? The accrued interest is simply part of the quotation convention for bonds and is used to calculate a "clean price" which is a way to remove the "sawtooth" coupon effect on price from the full price of the bond. $\endgroup$
    – Dom
    Aug 24, 2021 at 5:59
  • $\begingroup$ OK this makes sense, thanks a lot for the help. $\endgroup$ Aug 24, 2021 at 6:07
  • $\begingroup$ what's the 5/2 for in the formula 125/184 x 5/2? $\endgroup$
    – jamoreiras
    Nov 8, 2022 at 20:25
  • $\begingroup$ is it 5% *100 for the interest rate and 2 for number of interest payment per year, in this case semiannual = 2 payments per year? $\endgroup$
    – jamoreiras
    Nov 9, 2022 at 15:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.