Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backwards schedule bug? #20

Open
birgira opened this issue Nov 1, 2021 · 0 comments
Open

Backwards schedule bug? #20

birgira opened this issue Nov 1, 2021 · 0 comments

Comments

@birgira
Copy link

birgira commented Nov 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant