| 
					
	
	 I am building a bridge between Summit and QuantLib and have come across a payment schedule which I believe cannot currently be generated in QuantLib. Basically it has payments to be made on the 29th of each month, but with a settlement/start date not on the 29th. Normally I am passing the firstDate parameter to the Schedule class as the 29th of the relevant month of the first payment. However in my case the first date is in February 2009, so I cannot do this as 29th Feb 2009 is an invalid date. If I pass the 28th Feb, then most of my payments come out on the 28th, and if I set the end of month flag I get typically the
 30th/31st, neither of which is correct I believe the same issue arise if payments are supposed to happen on the 30th of the month. If someone can confirm this is indeed a case not currently handled, then I happy to take a look at the code to see if I can work out a solution which caters for this case, and which would be backwards compatible. Chris Higgs ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev  | 
			
| 
					
	
	 
		Hello Chris,
 
				no, it's not currently handled. (As a workaround, if the first date were in February but the last weren't, you might build it backwards from the 29th of the last month. But that's not likely--your schedules probably span a whole number of years...) Luigi On Thu, Oct 31, 2013 at 6:19 PM, Chris Higgs <[hidden email]> wrote: > I am building a bridge between Summit and QuantLib and have come across a > payment schedule which I believe cannot currently be generated in QuantLib. > Basically it has payments to be made on the 29th of each month, but with a > settlement/start date not on the 29th. Normally I am passing the firstDate > parameter to the Schedule class as the 29th of the relevant month of the > first payment. However in my case the first date is in February 2009, so I > cannot do this as 29th Feb 2009 is an invalid date. If I pass the 28th Feb, > then most of my payments come out on the 28th, and if I set the end of month > flag I get typically the 30th/31st, neither of which is correct I believe > the same issue arise if payments are supposed to happen on the 30th of the > month. > > If someone can confirm this is indeed a case not currently handled, then I > happy to take a look at the code to see if I can work out a solution which > caters for this case, and which would be backwards compatible. > > Chris Higgs > > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev  | 
			
| 
					
	 
				In reply to this post by Chris Higgs
			 
	may you please post target vector of dates to be reproduced? On Thu, Oct 31, 2013 at 6:19 PM, Chris Higgs <[hidden email]> wrote: 
 ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev  | 
			
| 
					
	
	 ate =EffDate = 20090827  
 MatDate = 20220829  Frequency = Semi-Annual 
 Payment
day of month = 29 
 Payment Date rule = Modified
Following 
 Payment Holiday Calendar = EUR 
Resulting
payment dates (according to Summit): 
20100226 
20100830 
20110228 
20110829 
20120229 
20120829 
20130228 
20130829 
20140228 
20140829 
20150227 
20150831 
20160229 
20160829 
20170228 
20170829 
20180228 
20180829 
20190228 
20190829 
20200228 
20200831 
20210226 
20210830 
20220228 
20220829 
I am guessing in this particular case that just
setting the Schedule to generate backwards from 20220829 and not setting firstDate or nextToLastDate might produce the correct result? However I
could produce other test cases where it would not work, for example 
        EffDate = 20090228  
        MatDate = 20220228 
        Payment Frequency = Annual 
        Payment day of month = 29 
I
believe that adding an extra optional parameter to the Schedule constructor
would allow this case to be internally handled but not break any existing code: 
        Schedule(Date effectiveDate, 
                 const Date& terminationDate, 
                 const Period& tenor, 
                 const Calendar& calendar, 
                
BusinessDayConvention convention, 
                 BusinessDayConvention
terminationDateConvention, 
                
DateGeneration::Rule rule, 
                 bool endOfMonth, 
                 const Date& firstDate = Date(), 
                 const
Date& nextToLastDate = Date() 
int
annDayOfMonth = 0); 
Setting
annDayOfMonth=31 is then the same as setting endOfMonth=true. Setting annDayOfMonth=29
or 30 will then trigger new functionality to generate schedules as above. Chris 
  On Thursday, 31 October 2013, 22:12, Ferdinando M. Ametrano <[hidden email]> wrote:   may you please post target vector of dates to be reproduced? On Thu, Oct 31, 2013 at 6:19 PM, Chris Higgs <[hidden email]> wrote: 
 ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev  | 
			
| 
					
	
	 I found that adding this code to the routine Calendar::advance allows the schedule to be generated as expected if annDay is passed as 29: ...         } else { Date d1 = d + n*unit; // we are sure the unit is Months or Years if (endOfMonth && isEndOfMonth(d)) return Calendar::endOfMonth(d1); else if (annDay > 0) { if (annDay >= Calendar::endOfMonth(d1).dayOfMonth()) return Calendar::endOfMonth(d1); else d1 = Date(annDay, d1.month(), d1.year()); } return adjust(d1, c); } } ... The rest of the changes involve only the passing of annDay as a new optional parameter to the Schedule constructor, and then on into the calls to Calendar::advance. Chris   On Friday, 1 November 2013, 8:56, Chris Higgs <[hidden email]> wrote:   ate =EffDate = 20090827  
 MatDate = 20220829  Frequency = Semi-Annual 
 Payment
day of month = 29 
 Payment Date rule = Modified
Following 
 Payment Holiday Calendar = EUR 
Resulting
payment dates (according to Summit): 
20100226 
20100830 
20110228 
20110829 
20120229 
20120829 
20130228 
20130829 
20140228 
20140829 
20150227 
20150831 
20160229 
20160829 
20170228 
20170829 
20180228 
20180829 
20190228 
20190829 
20200228 
20200831 
20210226 
20210830 
20220228 
20220829 
I am guessing in this particular case that just
setting the Schedule to generate backwards from 20220829 and not setting firstDate or nextToLastDate might produce the correct result? However I
could produce other test cases where it would not work, for example 
        EffDate = 20090228  
        MatDate = 20220228 
        Payment Frequency = Annual 
        Payment day of month = 29 
I
believe that adding an extra optional parameter to the Schedule constructor
would allow this case to be internally handled but not break any existing code: 
        Schedule(Date effectiveDate, 
                 const Date& terminationDate, 
                 const Period& tenor, 
                 const Calendar& calendar, 
                
BusinessDayConvention convention, 
                 BusinessDayConvention
terminationDateConvention, 
                
DateGeneration::Rule rule, 
                 bool endOfMonth, 
                 const Date& firstDate = Date(), 
                 const
Date& nextToLastDate = Date() 
int
annDayOfMonth = 0); 
Setting
annDayOfMonth=31 is then the same as setting endOfMonth=true. Setting annDayOfMonth=29
or 30 will then trigger new functionality to generate schedules as above. Chris 
  On Thursday, 31 October 2013, 22:12, Ferdinando M. Ametrano <[hidden email]> wrote:   may you please post target vector of dates to be reproduced? On Thu, Oct 31, 2013 at 6:19 PM, Chris Higgs <[hidden email]> wrote: 
 ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev  | 
			
| Free forum by Nabble | Edit this page | 
	
	
		