Finally fixed Negative time when bootstraping day before holidays

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Finally fixed Negative time when bootstraping day before holidays

Irakli Machabeli-2
Nando, Luigi,

Finally fixed the bug that causes negative time error around holidays.
Problem is the Libor constructor.  I do not know why UK exchange calendar
was hardcoded for All Libors but EUR one.

BBA web site says :
" or if that day is not both a London business day and a business day in the
principal financial centre of the currency concerned, the next following day
which is a business day in both centres shall be the Value Date. "

This implies that for fixing/settlement  day calculation one has to use
joint calendar of UK and financial centre.

Say on Feb 12 US bank sells deposit on spot terms (that's what Libor is
pretty much) , than settlement (in terms of BBA web site Value Date )  is
Feb 12 plus 2 business days that is Feb 17 since Feb 16 is holiday in US.

When bootstrapping procedure tries to value npv of floating leg of swap it
calls  IborCoupon::indexFixing()
Here we try to get settlement date using  fixingCalendar_ of
InterestRateIndex that is initialized  in Libor constructor to UK calendar
so first floating leg starts on holiday Feb 16 while another calendar in
USDLibor says that swap starts on Feb 17 ( by the way why Libor class needs
two separate calendars?)

            // forecast: 1) startDiscount
            Date fixingValueDate = index_->fixingCalendar().advance(
                fixing_date, index_->fixingDays(), Days);

Anyway the whole fix is to change initializer in Libor constructor


    Libor::Libor(const std::string& familyName,
                 const Period& tenor,
                 Natural settlementDays,
                 const Currency& currency,
                 const Calendar& financialCenterCalendar,
                 const DayCounter& dayCounter,
                 const Handle<YieldTermStructure>& h)
    : IborIndex(familyName, tenor, settlementDays, currency,
                // Fix !!!
                // UnitedKingdom(UnitedKingdom::Exchange),
                JointCalendar(UnitedKingdom(UnitedKingdom::Exchange),
                                   financialCenterCalendar,JoinHolidays),
                // End fix !!!
                liborConvention(tenor), liborEOM(tenor),
                dayCounter, h),
      jointCalendar_(JointCalendar(UnitedKingdom(UnitedKingdom::Exchange),
                                   financialCenterCalendar,
                                   JoinHolidays)) {

Regards,
Irakli

--------------------------------------------------
From: "Irakli Machabeli" <[hidden email]>
Sent: Thursday, February 12, 2009 10:09 AM
To: <[hidden email]>
Cc: "quantlib_users" <[hidden email]>
Subject: Re: [Quantlib-users] Negative time when bootstraping day before
holidays

> Luigi,
>
> Please let me know what files are included in the fix. I'll get source
> code and recompile.
> Since I'm using quantlib from C# I had to make changes to SWIG interface
> files, due to this upgrade to new version takes some time.
>
> Irakli
>
>
> --------------------------------------------------
> From: "Luigi Ballabio" <[hidden email]>
> Sent: Tuesday, February 03, 2009 5:27 AM
> To: "Irakli Machabeli" <[hidden email]>
> Cc: "quantlib_users" <[hidden email]>
> Subject: Re: [Quantlib-users] Negative time when bootstraping day before
> holidays
>
>> On Tue, 2009-01-20 at 09:30 -0500, Irakli Machabeli wrote:
>>> Same problem as reported by others. Joint calendar (US+UK). Every day
>>> before
>>> holiday I get an bootstrap error with negative time for both swap and
>>> treasury curves. Qiuantlib version 0.9.6.
>>>
>>> Has anyone solved this issue?
>>
>> It might be fixed in 0.9.7.  May you check it?
>>
>> Luigi
>>
>>
>> --
>>
>> Innovation is hard to schedule.
>> -- Dan Fylstra
>>
>>
>>

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Finally fixed Negative time when bootstraping day before holidays

Luigi Ballabio
On Fri, 2009-02-13 at 14:46 -0500, Irakli Machabeli wrote:
> Finally fixed the bug that causes negative time error around holidays.
> Problem is the Libor constructor.  I do not know why UK exchange calendar
> was hardcoded for All Libors but EUR one.
>
> BBA web site says :
> " or if that day is not both a London business day and a business day in the
> principal financial centre of the currency concerned, the next following day
> which is a business day in both centres shall be the Value Date. "

True, but before that it says:

"For all currencies other than EUR and GBP the period between Fixing
Date and Value Date will be two London business days after the Fixing
Date, or if that day is not both etc. etc."

which means that first, you advance two days on the London calendar;
then, you check that the day you get is not a holiday in the other
calendar.  It's not just a simple joint-calendar calculation.

> Say on Feb 12 US bank sells deposit on spot terms (that's what Libor is
> pretty much) , than settlement (in terms of BBA web site Value Date )  is
> Feb 12 plus 2 business days that is Feb 17 since Feb 16 is holiday in US.

True, but not because you advance two days on the joint calendar. What
happens is:
- from Feb 12 you advance two days on the London calendar to Feb 16;
- Feb 16 is a US holiday, so you advance further to Feb 17.

If you start on Feb 13 instead, what happens is:
- from Feb 13 you advance two days on the London calendar to Feb 17;
- Feb 17 is not a US holiday, so you stay there.  The fact that Feb 16
is a US holiday doesn't enter the calculation.

Anyway: the above was implemented correctly in QuantLib 0.9.7.  Did you
try that version to see if you still get an error?

Luigi


--

If you can't convince them, confuse them.
-- Harry S. Truman



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Finally fixed Negative time when bootstraping day before holidays

Irakli Machabeli-2
Luigi,

Issue is fixed in QuantLib 0.9.7

Thanks.

--------------------------------------------------
From: "Luigi Ballabio" <[hidden email]>
Sent: Monday, February 16, 2009 8:59 AM
To: "Irakli Machabeli" <[hidden email]>
Cc: <[hidden email]>; "quantlib_users"
<[hidden email]>
Subject: Re: Finally fixed Negative time when bootstraping day before
holidays

> On Fri, 2009-02-13 at 14:46 -0500, Irakli Machabeli wrote:
>> Finally fixed the bug that causes negative time error around holidays.
>> Problem is the Libor constructor.  I do not know why UK exchange calendar
>> was hardcoded for All Libors but EUR one.
>>
>> BBA web site says :
>> " or if that day is not both a London business day and a business day in
>> the
>> principal financial centre of the currency concerned, the next following
>> day
>> which is a business day in both centres shall be the Value Date. "
>
> True, but before that it says:
>
> "For all currencies other than EUR and GBP the period between Fixing
> Date and Value Date will be two London business days after the Fixing
> Date, or if that day is not both etc. etc."
>
> which means that first, you advance two days on the London calendar;
> then, you check that the day you get is not a holiday in the other
> calendar.  It's not just a simple joint-calendar calculation.
>
>> Say on Feb 12 US bank sells deposit on spot terms (that's what Libor is
>> pretty much) , than settlement (in terms of BBA web site Value Date )  is
>> Feb 12 plus 2 business days that is Feb 17 since Feb 16 is holiday in US.
>
> True, but not because you advance two days on the joint calendar. What
> happens is:
> - from Feb 12 you advance two days on the London calendar to Feb 16;
> - Feb 16 is a US holiday, so you advance further to Feb 17.
>
> If you start on Feb 13 instead, what happens is:
> - from Feb 13 you advance two days on the London calendar to Feb 17;
> - Feb 17 is not a US holiday, so you stay there.  The fact that Feb 16
> is a US holiday doesn't enter the calculation.
>
> Anyway: the above was implemented correctly in QuantLib 0.9.7.  Did you
> try that version to see if you still get an error?
>
> Luigi
>
>
> --
>
> If you can't convince them, confuse them.
> -- Harry S. Truman
>
>
>

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users