QuantLib Day Counts and Adjacent Bond Cash Flow Dates
Summary
The discussion identifies QuantLib functions for two common fixed-income date tasks. To measure the year fraction between dates under a chosen convention, use the corresponding day-counter object, such as Actual/360, and call its year-fraction method. QuantLib’s day-counter documentation lists supported conventions.
For a bond schedule, the answer points to cash-flow utilities that return the previous and next cash-flow dates around a given date. These provide the adjacent dates the questioner needs without manually searching every schedule entry. The exchange is a brief API pointer rather than a worked example: it does not explain edge cases around settlement dates, accrued interest, or coupon-date inclusivity, so users should consult the library documentation for the precise behavior in their context.
Key ideas
- QuantLib day-counter objects compute year fractions using selected conventions.
- Actual/360 is one example of a supported day-count convention.
- Cash-flow utilities can find the previous and next cash-flow dates relative to a date.
- The short answer refers users to the library documentation for convention and method details.
Tags
Full text
# Quantlib Day Count between dates # Quantlib Day Count between dates Need some help on following items regarding functions in Qunatlib: - Is there any function available to calculate time between two dates with specific day count convention. For Example, I want to know time between D1 and D2 using 30/360, Act/360, etc day count convention. - Can we know previous and next coupon dates for bonds on particular date using schedule or some other function in Quantlib. I see schedule provides all cash flow dates but need something which gives previous and next cash flow dates. ## Answer by Luigi Ballabio (score 4) https://quant.stackexchange.com/a/38125 - Yes. You can write, for instance, `Actual360().yearFraction(d1,d2)`. Look for the `DayCounter` class at http://quantlib.org/reference for docs and the list of the supported day-count conventions. - You can use the `CashFlows::previousCashFlowDate` and `CashFlows::nextCashFlowDate` methods. Again, see the link above for details.
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.