|
From: Luigi B. <lui...@gm...> - 2021-06-01 11:44:53
|
Hi,
no, each bespoke calendar instance is different.
Luigi
On Tue, Jun 1, 2021 at 1:31 PM HANISH SHARMA <han...@gm...>
wrote:
> Hi Luigi,
>
> Thank you for the explanation.
> This implementation sparks another line of thought.
>
> If I make 2 instances of BespokeCalendar (say obj =
> BespokeCalendar("Cal1") and obj2 = BespokeCalendar("Cal2")) and holidays
> to one of the instances, the code will behave in the same way as the
> previous implementation with Target class as they both are the instances of
> the same calendar class.
>
> Is my understanding correct?
>
> Regards
> Hanish Sharma
>
>
> On Tue, Jun 1, 2021 at 3:08 PM Luigi Ballabio <lui...@gm...>
> wrote:
>
>> ...and of course that wasn't tested. Here are the correct calls:
>>
>> obj2 = ql.BespokeCalendar("mycalendar")
>> obj2.addWeekend(ql.Saturday)
>> obj2.addWeekend(ql.Sunday)
>>
>> for d in ql.TARGET().holidayList(start_date, end_date):
>> obj2.addHoliday(d)
>>
>> obj2.addHoliday(my_new_holiday1)
>> obj2.addHoliday(my_new_holiday2)
>>
>>
>>
>> On Tue, Jun 1, 2021 at 11:32 AM Luigi Ballabio <lui...@gm...>
>> wrote:
>>
>>> Hello,
>>> instances of the same calendar share the added holidays. The
>>> rationale is that, when a new holiday is announced (for instance, next
>>> year's Platinum Jubilee in the UK) it's possible to add it to the relevant
>>> calendar just once at initialization instead of having to do it for each
>>> instance.
>>>
>>> If you want a particular calendar instance detached from all others, you
>>> can use the BespokeCalendar class, but in that case you'll start from a
>>> calendar without holidays and you'll have to add the whole list of them
>>> manually. You can do something like this:
>>>
>>> obj2 = ql.BespokeCalendar("mycalendar")
>>> obj2.addWeekday(ql.Saturday)
>>> obj2.addWeekday(ql.Sunday)
>>>
>>> for d in TARGET().holidayList(start_date, end_date):
>>> obj2.add(d)
>>>
>>> obj2.add(my_new_holiday1)
>>> obj2.add(my_new_holiday2)
>>>
>>> Hope this helps,
>>> Luigi
>>>
>>>
>>>
>>> On Tue, Jun 1, 2021 at 12:07 AM HANISH SHARMA <han...@gm...>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> Greetings,
>>>>
>>>> I have a question regarding the TARGET class.
>>>> I have created 2 instances of the target class "obj" and "obj2".
>>>> After this, I added 2 holidays in obj2 instance using addHoliday().
>>>>
>>>> Now, if I print the holidayList of both the instances, I get the same
>>>> result ie 2 added holidays in the holiday list of obj as well.
>>>> PFB the code snippet and output:
>>>> [image: image.png]
>>>> [image: image.png]
>>>>
>>>> Why is the output of obj.holidayList contains the holidays added in
>>>> obj2 instance?
>>>>
>>>> How can I get the holidaylist of obj exclusive to obj ie holidays added
>>>> in other instances do not become the part obj's holidaylist.
>>>>
>>>> Thank you in advance.
>>>>
>>>> Regards
>>>> Hanish Sharma
>>>> _______________________________________________
>>>> QuantLib-users mailing list
>>>> Qua...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>>
>>>
|