Skip to content
All library documents

QuantLib Coupon Dates and Fixed-Rate Bond Cash Flow Amounts

Article Quant Q&A · Author: Roshan Yadav

Summary

This example shows how to inspect payment dates and amounts for a fixed-rate bond built in QuantLib. It creates a monthly schedule, adds a fixed-rate coupon leg and a maturity redemption, and reads each cash flow from the resulting bond. The displayed first coupon is calculated using the accrual period from May 10 to June 10, 2020, producing the reported amount for that period.

The question’s larger expected coupon uses June 11 as its accrual end date, which does not match the generated schedule. The answer resolves the discrepancy by checking the first coupon’s accrual start and end dates directly. This illustrates that coupon calculations depend on the dates actually generated by the schedule, not a separately assumed date. The example is limited to its stated calendar, convention, day-count basis, and bond setup; it does not cover other schedule conventions or QuantLib instruments.

Key ideas

  • A bond’s cash flows can be inspected as date and amount pairs.
  • The coupon amount depends on the accrual dates generated by the schedule.
  • The example’s first accrual period ends on June 10, rather than June 11.
  • Inspecting a coupon’s accrual start and end dates helps explain a cash flow discrepancy.
  • The reported amounts apply to the specific conventions and dates used in the example.

Tags

Full text
# Is there any way to get cashflow amount including cashflow date in QuantLib?


# Is there any way to get cashflow amount including cashflow date in QuantLib?












```
import QuantLib as ql
import datetime

today = ql.Date(10,5,2020)
ql.Settings.instance().evaluationDate = today
issueDate = ql.Date(10,5,2020)
maturityDate = ql.Date(9, 7, 2021)
tenor = ql.Period(ql.Monthly)
dayCount = ql.Actual365Fixed()
bussinessConvention = ql.Unadjusted
dateGeneration = ql.DateGeneration.Forward
monthEnd = False
calendar = ql.NullCalendar()
faceValue = 10000000
coupon = 0.07
schedule = ql.Schedule(issueDate, maturityDate,tenor, calendar, ql.Unadjusted, ql.Unadjusted, dateGeneration,False)

fixed_rate_leg = ql.FixedRateLeg(schedule=schedule, dayCount=dayCount,
                                            nominals=[faceValue], couponRates=[coupon]) + (ql.Redemption(faceValue,maturityDate),)

bond = ql.Bond(0, calendar, 100.0,
                maturityDate, issueDate, fixed_rate_leg)

print([(a.date(),a.amount() )for a in bond.cashflows()])

[(Date(10,6,2020), 59452.05479451987), (Date(10,7,2020), 57534.24657534145), (Date(10,8,2020), 59452.05479451987), (Date(10,9,2020), 59452.05479451987), (Date(10,10,2020), 57534.24657534145), (Date(10,11,2020), 59452.05479451987), (Date(10,12,2020), 57534.24657534145), (Date(10,1,2021), 59452.05479451987), (Date(10,2,2021), 59452.05479451987), (Date(10,3,2021), 53698.63013698684), (Date(10,4,2021), 59452.05479451987), (Date(10,5,2021), 57534.24657534145), (Date(10,6,2021), 59452.05479451987), (Date(9,7,2021), 55616.43835616526), (Date(9,7,2021), 10000000.0)]

here for example expected cashflow on first cashflow date is.

date  =  10/06/2020
amount = 61369.86301369864

above amount calculation explanation:
yr_frac = ql.Actual365Fixed().yearFraction(ql.Date(10,5,2020),ql.Date(11,6,2020))
amount = faceValue*yr_frac*coupon
amount = 61369.86301369864

```
```

## Answer by David Duarte (score 1)

https://quant.stackexchange.com/a/72207

If you check the dates that were generated, you will see 10-06-2020 and not 11-06-2020..

```
for cf in map(ql.as_fixed_rate_coupon, bond.cashflows()[:1]):
    print(cf.accrualStartDate().ISO(), cf.accrualEndDate().ISO(), cf.amount())
```

2020-05-10 2020-06-10 59452.05479451987

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.