|
From: Luigi B. <lui...@gm...> - 2017-10-30 11:28:40
|
Hello Simon,
I'm guessing that Dimitri's slides contain the output of the library at
the time he wrote them. The schedule code has changed since, and now you
get the new output. I'm not sure which result is "correct"; you're telling
the schedule to enforce end of months and passing an end date in the middle
of the month, which might be a bit of a corner case. In any case, you can
select the behavior by changing the termination date convention; by passing
Unadjusted, you'll get Dimitri's output.
Luigi
On Mon, Oct 30, 2017 at 10:14 AM Simon Courtenage <cou...@gm...>
wrote:
> Hi all,
>
> I was reading Dimitri Reiswich's slides on Quantlib (found at
> http://quantlib.org/slides/dima-ql-intro-1.pdf), and in particular, the
> slides about the Schedule class. On slide 36, there is some example code to
> show how to construct a Schedule. This code is below:
>
> Date begin(30,September ,2009) , end(15,Jun ,2012);
> Calendar myCal=Japan ();
>
> BusinessDayConvention bdC=BusinessDayConvention(Following );
> Period myTenor(6,Months );
> DateGeneration ::Rule myRule=DateGeneration :: Forward;
>
> Schedule mySched(begin ,end ,myTenor ,myCal ,bdC ,bdC ,myRule ,true);
>
> std::vector <Date > finalSched=mySched.dates ();
> BOOST_FOREACH(Date d,finalSched) std::cout << d << std::endl;
>
> On slide 37 is its example output, which is:
>
> September 30th, 2009
> March 31st, 2010
> September 30th, 2010
> March 31st, 2011
> September 30th, 2011
> March 30th, 2012
> June 15th, 2012
>
> When I compiled and ran this code myself, I got
>
> June 15th, 2012
>
> September 30th, 2009
>
> March 31st, 2010
>
> September 30th, 2010
>
> March 31st, 2011
>
> September 30th, 2011
>
> March 30th, 2012
>
> June 29th, 2012
> The difference being the last date - Jun 29th instead of Jun 15th. The last date is later than the termination date provided in the constructor call.
>
> My question is which behaviour is expected and correct? June 15th (as in Dimitri's slides) or June 29th, the actual result?
>
> If Dimitri's version is correct, then I suspect that this code after the case statements for date calculation in the Schedule constructor (dealing with effective dates) will need to change, since its the code responsible for changing June 15th t June 29th in the example above.
>
> if (terminationDateConvention != Unadjusted) {
> dates_.front() = calendar_.endOfMonth(dates_.front());
> dates_.back() = calendar_.endOfMonth(dates_.back());
> }
>
> I'm compiling against the latest QL code cloned from github yesterday.
>
> Thanks
>
> Simon
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> QuantLib-dev mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>
|