[QL 0.9.7] DateGeneration ThirdWednesday rule issues

Posted by radupaul on
URL: http://quantlib.414.s1.nabble.com/QL-0-9-7-DateGeneration-ThirdWednesday-rule-issues-tp7667.html

QL: 0.9.6/0.9.7

Hi:

Apparently there are some problems (?) when using a Schedule with the DateGeneration::ThirdWednesday rule (e.g. for an IMM swap, use Unadjusted for all conventions, some arbitrary effective start date, End-of-Month=False) -  we would appreciate developer/user comments if this is the desired behavior and/or other Quantlib sections are impacted (doesn't seem so though...):

- when the termination date is an IMM date it is inserted twice in the schedule.
- when a NextToLastDate that is an IMM date is used, it is possible to be skipped if the first date occurs on date with its day part > the next to last day part (e.g. firstDate=20090916 and nextToLastDate=20110615, with termination=20110921), then the generated schedule is:
{start date, 20090916, ..., March 2011 IMM date, Sep 2011 IMM Date} (no June 2011 IMM)

In the Schedule.cpp code, the calendar advances with the required number of months and the adjustment to IMM dates is done after all dates are filled - this explains the skipping of NextToLastDate - I could not track why the duplicated TerminationDate.

Anyway, we've attached the proposed solution (only the relevant sections in Schedule.cpp), essentially adding a "break" in a SWITCH statement (case DateGeneration::ThirdWednesday) and adjusting to IMM dates after each calendar advance -

Thanks, Adel/Radu


corrected_schedule.cpp