QuantLib.jl
QuantLib.jl copied to clipboard
Backwards schedule bug?
I am getting wrong schedule output in couple of situations. Here is one example:
using QuantLib
effectiveDate = Date(2021,9,15)
terminationDate = Date(2032,9,1)
convention = QuantLib.Time.Unadjusted()
termDateConvention = QuantLib.Time.Unadjusted()
cal = QuantLib.Time.TargetCalendar()
tenor = QuantLib.Time.TenorPeriod(ql.Time.Monthly())
QuantLib.Time.Schedule(effectiveDate,
terminationDate,
tenor,
convention,
termDateConvention,
QuantLib.Time.DateGenerationBackwards(),
false,
cal).dates
The output starts as follows:
134-element Vector{Date}:
2021-09-15
2021-09-01
2021-10-01
I.e., there is one too many elements in the output vector (wrongly includes 2021-09-01). The issue lies in the function get_size. Instead of returning Int(ceil(ceil(Dates.value(td - ed) / 30) / Dates.value(p))), it looks like the function should return 12*(Dates.year(td) - Dates.year(ed)) + (Dates.month(td) - Dates.month(ed)) + 1