Re: joint calendar
Posted by Luigi Ballabio-2 on
URL: http://quantlib.414.s1.nabble.com/joint-calendar-tp2345p2346.html
At 1:56 PM +0000 1/24/03, Chak Jack Wong wrote:
>Something very simple, how can I specify NewYork and London as calendar?
Jack,
it's not entirely clear to me whether you want a calendar
whose set of business days is the union or the intersection of the
set of business days of New York and London. However, the principle
is the same: you use the Composite pattern. You should derive a new
calendar and a corresponding calendar implementation. The constructor
of the new Calendar class takes two Calendars c1 and c2 and just
passes them to its implementation, which stores them. The
implementation defines its isBusinessDay(date) method either as:
return c1.isBusinessDay(date) || c2.isBusinessDay(date);
or:
return c1.isBusinessDay(date) && c2.isBusinessDay(date);
depending on the desired behavior. You'll also have to implement its
name() method by composing c1.name() and c2.name() somehow.
You're welcome to come back with some tentative code if you get into
any problem---I'll try and give you a hand.
Later,
Luigi