problem with ZeroCurve and ActualActual(Bond) day count

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

problem with ZeroCurve and ActualActual(Bond) day count

Knox, Matt
I am trying to construct zero curves using the ZeroCurve class (using the Python wrappers), and I seem to run into problems when using the ActualActual(Bond) day count convention. It thinks that different input dates are actually the same date.
 
The best way I can explain this is with an example. Consider the following code:
 
#.....................................................................
import QuantLib as ql
import traceback
 
start_date = ql.Date(30,9,2013)
 
# 50 years of data points spaced 10 days apart
dates = [(start_date + x * 10) for x in range(365 * 5)]
rates = [0.02 for _ in dates]
 
for daycount, description in [
    (ql.ActualActual(ql.ActualActual.Bond), "ActualActual(Bond)"),
    (ql.ActualActual(ql.ActualActual.ISDA), "ActualActual(ISDA)"),
    (ql.Actual360(), "Actual360()"),
    (ql.Thirty360(), "Thirty360()"),
]:
    try:
        ql.ZeroCurve(dates, rates, daycount)
        print "success: %s" % description
    except:
        print "failure: %s" % description
        print traceback.format_exc()
# and the output....
failure: ActualActual(Bond)
Traceback (most recent call last):
  File "foobar.py", line 47, in <module>
    ql.ZeroCurve(dates, rates, daycount)
  File "C:\analytics\ext\python27\lib\site-packages\QuantLib\QuantLib.py", line 10028, in __init__
    this = _QuantLib.new_ZeroCurve(*args)
RuntimeError: two dates correspond to the same time under this curve's day count convention
 
success: ActualActual(ISDA)
success: Actual360()
success: Thirty360()
 
#....................................
This is using Python 2.7 and QuantLib 1.3
 
Any idea what is going on?
 
Any help would be greatly appreciated. Thanks!
 
- Matt Knox
 


NOTICE: Confidential message which may be privileged. Unauthorized use/disclosure prohibited. If received in error, please go to www.td.com/legal for instructions.
AVIS : Message confidentiel dont le contenu peut être privilégié. Utilisation/divulgation interdites sans permission. Si reçu par erreur, prière d'aller au www.td.com/francais/avis_juridique pour des instructions.


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: problem with ZeroCurve and ActualActual(Bond) day count

Peter Caspers-4
The dates are actually different, but the year fraction is the same for
groups of several of dates under ActualActual/ICMA because no reference
period is specified in TermStructure::timeFromReference(), therefore
it is set equal to the period itself, therefore (largely) yearfractions
of the form n/12 are produced. Since the spacing between your dates is
only 10 days, more than one date can (and does) produce the same year
fraction.

So I guess technically the behaviour is expected (also, with a meaningful
message thrown).

The question is, what do you want to achieve exactly ?

best regards
   Peter


"Knox, Matt" <[hidden email]> writes:

> I am trying to construct zero curves using the ZeroCurve class (using
> the Python wrappers), and I seem to run into problems when using the
> ActualActual(Bond) day count convention. It thinks that different
> input dates are actually the same date.
>  
> The best way I can explain this is with an example. Consider the
> following code:
>  
> #.....................................................................
> import QuantLib as ql
> import traceback
>  
> start_date = ql.Date(30,9,2013)
>  
> # 50 years of data points spaced 10 days apart
> dates = [(start_date + x * 10) for x in range(365 * 5)]
> rates = [0.02 for _ in dates]
>  
> for daycount, description in [
>     (ql.ActualActual(ql.ActualActual.Bond), "ActualActual(Bond)"),
>     (ql.ActualActual(ql.ActualActual.ISDA), "ActualActual(ISDA)"),
>     (ql.Actual360(), "Actual360()"),
>     (ql.Thirty360(), "Thirty360()"),
> ]:
>     try:
>         ql.ZeroCurve(dates, rates, daycount)
>         print "success: %s" % description
>     except:
>         print "failure: %s" % description
>         print traceback.format_exc()
> # and the output....
> failure: ActualActual(Bond)
> Traceback (most recent call last):
>   File "foobar.py", line 47, in <module>
>     ql.ZeroCurve(dates, rates, daycount)
>   File "C:\analytics\ext\python27\lib\site-packages\QuantLib\
> QuantLib.py", line 10028, in __init__
>     this = _QuantLib.new_ZeroCurve(*args)
> RuntimeError: two dates correspond to the same time under this
> curve's day count convention
>  
> success: ActualActual(ISDA)
> success: Actual360()
> success: Thirty360()
>  
> #....................................
> This is using Python 2.7 and QuantLib 1.3
>  
> Any idea what is going on?
>  
> Any help would be greatly appreciated. Thanks!
>  
> - Matt Knox
>  
>
>
> NOTICE: Confidential message which may be privileged. Unauthorized
> use/disclosure prohibited. If received in error, please go to
> www.td.com/legal for instructions.
> AVIS : Message confidentiel dont le contenu peut être privilégié.
> Utilisation/divulgation interdites sans permission. Si reçu par
> erreur, prière d'aller au www.td.com/francais/avis_juridique pour des
> instructions.
>
>
>
> ------------------------------------------------------------------------------
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: problem with ZeroCurve and ActualActual(Bond) day count

Knox, Matt
Thanks Peter. The situation is as follows:

I have a pre-calculated zero curve which was boot strapped from government of Canada bonds. According to this document http://iiac.ca/wp-content/uploads/Canadian-Conventions-in-FI-Markets.pdf , the day count convention for these bonds would be ActualActual(Bond) if I am understanding it correctly - see footnote at bottom of page 6 of that document. I want to use this curve to calculate some shocks on a bond portfolio, as well as a stream of cash flows (representing pension liabilities). My thinking was that when I construct the zero curve, I should match the day count convention of the bonds that were used to build it. Furthermore, for apples to apples comparison with the liabilities, I should use the same day count on the liability cash flows. However, due to the spacing of the data points in the pre-calculated curve, I would have to pre-adjust the curve to pass it into the ZeroCurve constructor if I am to use the ActualActual(Bond) day count convention.

So my options seem to be: adjust the curve, or pick another day count convention that is "good enough".

Does my thinking make sense here? Or am I going about this the wrong way? Thanks for the reply, appreciate any insight you can offer.

- Matt

-----Original Message-----
From: Peter Caspers [mailto:[hidden email]]
Sent: November 16, 2013 3:02 PM
To: Knox, Matt
Cc: '[hidden email]'
Subject: Re: [Quantlib-users] problem with ZeroCurve and ActualActual(Bond) day count

The dates are actually different, but the year fraction is the same for groups of several of dates under ActualActual/ICMA because no reference period is specified in TermStructure::timeFromReference(), therefore it is set equal to the period itself, therefore (largely) yearfractions of the form n/12 are produced. Since the spacing between your dates is only 10 days, more than one date can (and does) produce the same year fraction.

So I guess technically the behaviour is expected (also, with a meaningful message thrown).

The question is, what do you want to achieve exactly ?

best regards
   Peter


"Knox, Matt" <[hidden email]> writes:

> I am trying to construct zero curves using the ZeroCurve class (using
> the Python wrappers), and I seem to run into problems when using the
> ActualActual(Bond) day count convention. It thinks that different
> input dates are actually the same date.
>  
> The best way I can explain this is with an example. Consider the
> following code:
>  
> #.....................................................................
> import QuantLib as ql
> import traceback
>  
> start_date = ql.Date(30,9,2013)
>  
> # 50 years of data points spaced 10 days apart dates = [(start_date +
> x * 10) for x in range(365 * 5)] rates = [0.02 for _ in dates]
>  
> for daycount, description in [
>     (ql.ActualActual(ql.ActualActual.Bond), "ActualActual(Bond)"),
>     (ql.ActualActual(ql.ActualActual.ISDA), "ActualActual(ISDA)"),
>     (ql.Actual360(), "Actual360()"),
>     (ql.Thirty360(), "Thirty360()"),
> ]:
>     try:
>         ql.ZeroCurve(dates, rates, daycount)
>         print "success: %s" % description
>     except:
>         print "failure: %s" % description
>         print traceback.format_exc()
> # and the output....
> failure: ActualActual(Bond)
> Traceback (most recent call last):
>   File "foobar.py", line 47, in <module>
>     ql.ZeroCurve(dates, rates, daycount)
>   File "C:\analytics\ext\python27\lib\site-packages\QuantLib\
> QuantLib.py", line 10028, in __init__
>     this = _QuantLib.new_ZeroCurve(*args)
> RuntimeError: two dates correspond to the same time under this curve's
> day count convention
>  
> success: ActualActual(ISDA)
> success: Actual360()
> success: Thirty360()
>  
> #....................................
> This is using Python 2.7 and QuantLib 1.3
>  
> Any idea what is going on?
>  
> Any help would be greatly appreciated. Thanks!
>  
> - Matt Knox
>  
>
>
> NOTICE: Confidential message which may be privileged. Unauthorized
> use/disclosure prohibited. If received in error, please go to
> www.td.com/legal for instructions.
> AVIS : Message confidentiel dont le contenu peut être privilégié.
> Utilisation/divulgation interdites sans permission. Si reçu par
> erreur, prière d'aller au www.td.com/francais/avis_juridique pour des
> instructions.
>
>
>
> ----------------------------------------------------------------------
> -------- DreamFactory - Open Source REST & JSON Services for HTML5 &
> Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External
> API Access Free app hosting. Or install the open source package on any
> LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.c
> lktrk _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

NOTICE: Confidential message which may be privileged. Unauthorized use/disclosure prohibited. If received in error, please go to www.td.com/legal for instructions.
AVIS : Message confidentiel dont le contenu peut être privilégié. Utilisation/divulgation interdites sans permission. Si reçu par erreur, prière d'aller au www.td.com/francais/avis_juridique pour des instructions.

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: problem with ZeroCurve and ActualActual(Bond) day count

Peter Caspers-4
Hi Matt,

   from what i know ActAct/ICMA is used for bond accrual and yield
(and other bond analytics) calculation. What I also saw is that spread
quotations over a reference curve (e.g. a swap curve) for a (single)
bond are following the bond's day count and yield convention in the
sense that the reference curve is rebootstrapped using the bond's
ActAct/ICMA day count convention (and also bond yield compounding) for
the stripped zero yields. However in my understanding this is clearly
dependent on the single bond to be valued and not applicable to a situation
where a zero curve or a spread term structure over a reference curve is
built from several bonds, as in your case.

So my next question would be how exactly your zero curve was calculated
(what you call precalculated curve below). I could imagine that some
instrument independent day counter was used such as ActAct/ISDA) or
Act365(Fixed). Do you have any details on that ?

kind regards
   Peter


"Knox, Matt" <[hidden email]> writes:

> Thanks Peter. The situation is as follows:
>
> I have a pre-calculated zero curve which was boot strapped from
> government of Canada bonds. According to this document
> http://iiac.ca/wp-content/uploads/Canadian-Conventions-in-FI-Markets.pdf
> , the day count convention for these bonds would be ActualActual(Bond)
> if I am understanding it correctly - see footnote at bottom of page 6
> of that document. I want to use this curve to calculate some shocks on
> a bond portfolio, as well as a stream of cash flows (representing
> pension liabilities). My thinking was that when I construct the zero
> curve, I should match the day count convention of the bonds that were
> used to build it. Furthermore, for apples to apples comparison with
> the liabilities, I should use the same day count on the liability cash
> flows. However, due to the spacing of the data points in the
> pre-calculated curve, I would have to pre-adjust the curve to pass it
> into the ZeroCurve constructor if I am to use the ActualActual(Bond)
> day count convention.
>
> So my options seem to be: adjust the curve, or pick another day count convention that is "good enough".
>
> Does my thinking make sense here? Or am I going about this the wrong way? Thanks for the reply, appreciate any insight you can offer.
>
> - Matt
>
> -----Original Message-----
> From: Peter Caspers [mailto:[hidden email]]
> Sent: November 16, 2013 3:02 PM
> To: Knox, Matt
> Cc: '[hidden email]'
> Subject: Re: [Quantlib-users] problem with ZeroCurve and ActualActual(Bond) day count
>
> The dates are actually different, but the year fraction is the same
> for groups of several of dates under ActualActual/ICMA because no
> reference period is specified in TermStructure::timeFromReference(),
> therefore it is set equal to the period itself, therefore (largely)
> yearfractions of the form n/12 are produced. Since the spacing between
> your dates is only 10 days, more than one date can (and does) produce
> the same year fraction.
>
> So I guess technically the behaviour is expected (also, with a meaningful message thrown).
>
> The question is, what do you want to achieve exactly ?
>
> best regards
>    Peter
>
>
> "Knox, Matt" <[hidden email]> writes:
>
>> I am trying to construct zero curves using the ZeroCurve class (using
>> the Python wrappers), and I seem to run into problems when using the
>> ActualActual(Bond) day count convention. It thinks that different
>> input dates are actually the same date.
>>  
>> The best way I can explain this is with an example. Consider the
>> following code:
>>  
>> #.....................................................................
>> import QuantLib as ql
>> import traceback
>>  
>> start_date = ql.Date(30,9,2013)
>>  
>> # 50 years of data points spaced 10 days apart dates = [(start_date +
>> x * 10) for x in range(365 * 5)] rates = [0.02 for _ in dates]
>>  
>> for daycount, description in [
>>     (ql.ActualActual(ql.ActualActual.Bond), "ActualActual(Bond)"),
>>     (ql.ActualActual(ql.ActualActual.ISDA), "ActualActual(ISDA)"),
>>     (ql.Actual360(), "Actual360()"),
>>     (ql.Thirty360(), "Thirty360()"),
>> ]:
>>     try:
>>         ql.ZeroCurve(dates, rates, daycount)
>>         print "success: %s" % description
>>     except:
>>         print "failure: %s" % description
>>         print traceback.format_exc()
>> # and the output....
>> failure: ActualActual(Bond)
>> Traceback (most recent call last):
>>   File "foobar.py", line 47, in <module>
>>     ql.ZeroCurve(dates, rates, daycount)
>>   File "C:\analytics\ext\python27\lib\site-packages\QuantLib\
>> QuantLib.py", line 10028, in __init__
>>     this = _QuantLib.new_ZeroCurve(*args)
>> RuntimeError: two dates correspond to the same time under this curve's
>> day count convention
>>  
>> success: ActualActual(ISDA)
>> success: Actual360()
>> success: Thirty360()
>>  
>> #....................................
>> This is using Python 2.7 and QuantLib 1.3
>>  
>> Any idea what is going on?
>>  
>> Any help would be greatly appreciated. Thanks!
>>  
>> - Matt Knox
>>  
>>
>>
>> NOTICE: Confidential message which may be privileged. Unauthorized
>> use/disclosure prohibited. If received in error, please go to
>> www.td.com/legal for instructions.
>> AVIS : Message confidentiel dont le contenu peut être privilégié.
>> Utilisation/divulgation interdites sans permission. Si reçu par
>> erreur, prière d'aller au www.td.com/francais/avis_juridique pour des
>> instructions.
>>
>>
>>
>> ----------------------------------------------------------------------
>> -------- DreamFactory - Open Source REST & JSON Services for HTML5 &
>> Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External
>> API Access Free app hosting. Or install the open source package on any
>> LAMP server.
>> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
>> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.c
>> lktrk _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> NOTICE: Confidential message which may be privileged. Unauthorized use/disclosure prohibited. If received in error, please go to www.td.com/legal for instructions.
> AVIS : Message confidentiel dont le contenu peut être privilégié. Utilisation/divulgation interdites sans permission. Si reçu par erreur, prière d'aller au www.td.com/francais/avis_juridique pour des instructions.

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: problem with ZeroCurve and ActualActual(Bond) day count

Knox, Matt
Thanks Peter. It looks like the curve was built assuming ActAct/ICMA (or ISMA in QuantLib terms). Based on that, my assumption would be that the "lesser of the evils" would be to manipulate the curve so that it can be input into the QuantLib ZeroCurve class using the same ActAct/ICMA day count (i.e.. Reduce the number of data points in the yield curve before passing in to QuantLib). As opposed to choosing a different day count convention that accepts the curve as-is. Would you agree with that?

Also, to better understand what the ZeroCurve class is doing to the dates I input with the ActAct/ICMA day count, is it essentially going to round them to the nearest month? For example, if one of the points on the curve is 13-jan-2014, internally QuantLib could translate it to some arbitrary date in Jan-2014? Will it specifically round it to 31-jan-2014 (or 1-jan-2014)?

Thank you so much for your help,

- Matt

-----Original Message-----
From: Peter Caspers [mailto:[hidden email]]
Sent: November 18, 2013 3:26 PM
To: Knox, Matt
Cc: '[hidden email]'
Subject: Re: [Quantlib-users] problem with ZeroCurve and ActualActual(Bond) day count

Hi Matt,

   from what i know ActAct/ICMA is used for bond accrual and yield (and other bond analytics) calculation. What I also saw is that spread quotations over a reference curve (e.g. a swap curve) for a (single) bond are following the bond's day count and yield convention in the sense that the reference curve is rebootstrapped using the bond's ActAct/ICMA day count convention (and also bond yield compounding) for the stripped zero yields. However in my understanding this is clearly dependent on the single bond to be valued and not applicable to a situation where a zero curve or a spread term structure over a reference curve is built from several bonds, as in your case.

So my next question would be how exactly your zero curve was calculated (what you call precalculated curve below). I could imagine that some instrument independent day counter was used such as ActAct/ISDA) or Act365(Fixed). Do you have any details on that ?

kind regards
   Peter


"Knox, Matt" <[hidden email]> writes:

> Thanks Peter. The situation is as follows:
>
> I have a pre-calculated zero curve which was boot strapped from
> government of Canada bonds. According to this document
> http://iiac.ca/wp-content/uploads/Canadian-Conventions-in-FI-Markets.p
> df , the day count convention for these bonds would be
> ActualActual(Bond) if I am understanding it correctly - see footnote
> at bottom of page 6 of that document. I want to use this curve to
> calculate some shocks on a bond portfolio, as well as a stream of cash
> flows (representing pension liabilities). My thinking was that when I
> construct the zero curve, I should match the day count convention of
> the bonds that were used to build it. Furthermore, for apples to
> apples comparison with the liabilities, I should use the same day
> count on the liability cash flows. However, due to the spacing of the
> data points in the pre-calculated curve, I would have to pre-adjust
> the curve to pass it into the ZeroCurve constructor if I am to use the
> ActualActual(Bond) day count convention.
>
> So my options seem to be: adjust the curve, or pick another day count convention that is "good enough".
>
> Does my thinking make sense here? Or am I going about this the wrong way? Thanks for the reply, appreciate any insight you can offer.
>
> - Matt
>
> -----Original Message-----
> From: Peter Caspers [mailto:[hidden email]]
> Sent: November 16, 2013 3:02 PM
> To: Knox, Matt
> Cc: '[hidden email]'
> Subject: Re: [Quantlib-users] problem with ZeroCurve and
> ActualActual(Bond) day count
>
> The dates are actually different, but the year fraction is the same
> for groups of several of dates under ActualActual/ICMA because no
> reference period is specified in TermStructure::timeFromReference(),
> therefore it is set equal to the period itself, therefore (largely)
> yearfractions of the form n/12 are produced. Since the spacing between
> your dates is only 10 days, more than one date can (and does) produce
> the same year fraction.
>
> So I guess technically the behaviour is expected (also, with a meaningful message thrown).
>
> The question is, what do you want to achieve exactly ?
>
> best regards
>    Peter
>
>
> "Knox, Matt" <[hidden email]> writes:
>
>> I am trying to construct zero curves using the ZeroCurve class (using
>> the Python wrappers), and I seem to run into problems when using the
>> ActualActual(Bond) day count convention. It thinks that different
>> input dates are actually the same date.
>>  
>> The best way I can explain this is with an example. Consider the
>> following code:
>>  
>> #.....................................................................
>> import QuantLib as ql
>> import traceback
>>  
>> start_date = ql.Date(30,9,2013)
>>  
>> # 50 years of data points spaced 10 days apart dates = [(start_date +
>> x * 10) for x in range(365 * 5)] rates = [0.02 for _ in dates]
>>  
>> for daycount, description in [
>>     (ql.ActualActual(ql.ActualActual.Bond), "ActualActual(Bond)"),
>>     (ql.ActualActual(ql.ActualActual.ISDA), "ActualActual(ISDA)"),
>>     (ql.Actual360(), "Actual360()"),
>>     (ql.Thirty360(), "Thirty360()"),
>> ]:
>>     try:
>>         ql.ZeroCurve(dates, rates, daycount)
>>         print "success: %s" % description
>>     except:
>>         print "failure: %s" % description
>>         print traceback.format_exc()
>> # and the output....
>> failure: ActualActual(Bond)
>> Traceback (most recent call last):
>>   File "foobar.py", line 47, in <module>
>>     ql.ZeroCurve(dates, rates, daycount)
>>   File "C:\analytics\ext\python27\lib\site-packages\QuantLib\
>> QuantLib.py", line 10028, in __init__
>>     this = _QuantLib.new_ZeroCurve(*args)
>> RuntimeError: two dates correspond to the same time under this
>> curve's day count convention
>>  
>> success: ActualActual(ISDA)
>> success: Actual360()
>> success: Thirty360()
>>  
>> #....................................
>> This is using Python 2.7 and QuantLib 1.3
>>  
>> Any idea what is going on?
>>  
>> Any help would be greatly appreciated. Thanks!
>>  
>> - Matt Knox
>>  
>>
>>
>> NOTICE: Confidential message which may be privileged. Unauthorized
>> use/disclosure prohibited. If received in error, please go to
>> www.td.com/legal for instructions.
>> AVIS : Message confidentiel dont le contenu peut être privilégié.
>> Utilisation/divulgation interdites sans permission. Si reçu par
>> erreur, prière d'aller au www.td.com/francais/avis_juridique pour des
>> instructions.
>>
>>
>>
>> ---------------------------------------------------------------------
>> -
>> -------- DreamFactory - Open Source REST & JSON Services for HTML5 &
>> Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and
>> External API Access Free app hosting. Or install the open source
>> package on any LAMP server.
>> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
>> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.
>> c lktrk _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> NOTICE: Confidential message which may be privileged. Unauthorized use/disclosure prohibited. If received in error, please go to www.td.com/legal for instructions.
> AVIS : Message confidentiel dont le contenu peut être privilégié. Utilisation/divulgation interdites sans permission. Si reçu par erreur, prière d'aller au www.td.com/francais/avis_juridique pour des instructions.

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: problem with ZeroCurve and ActualActual(Bond) day count

Peter Caspers-4
I still think that this only makes sense, if one bond (or a group of bonds with identical periods) is used, otherwise a date does not have a unique associated time w.r.t. ActActISMA. Maybe someone can jump in if I am missing something here ?
 
Apart from this in QL the time measurement in termstructures does not allow for a reference period structure from what I can see, i.e. the reference period is always assumed to be equal to the period to measure. Therefore from my point of view you should not use ActActISMA for a termstructure's day counter. Even the use case I outlined above (single bond spread quotation) would not work out of the box in QL.
 
Personally I would go for ActActISDA as the termstructures daycounter. This seems a reasonable solution, also perfectly fitting into QL.
 
--- Peter


On 18 November 2013 22:08, Knox, Matt <[hidden email]> wrote:
Thanks Peter. It looks like the curve was built assuming ActAct/ICMA (or ISMA in QuantLib terms). Based on that, my assumption would be that the "lesser of the evils" would be to manipulate the curve so that it can be input into the QuantLib ZeroCurve class using the same ActAct/ICMA day count (i.e.. Reduce the number of data points in the yield curve before passing in to QuantLib). As opposed to choosing a different day count convention that accepts the curve as-is. Would you agree with that?

Also, to better understand what the ZeroCurve class is doing to the dates I input with the ActAct/ICMA day count, is it essentially going to round them to the nearest month? For example, if one of the points on the curve is 13-jan-2014, internally QuantLib could translate it to some arbitrary date in Jan-2014? Will it specifically round it to 31-jan-2014 (or 1-jan-2014)?

Thank you so much for your help,

- Matt

-----Original Message-----
From: Peter Caspers [mailto:[hidden email]]
Sent: November 18, 2013 3:26 PM
To: Knox, Matt
Cc: '[hidden email]'
Subject: Re: [Quantlib-users] problem with ZeroCurve and ActualActual(Bond) day count

Hi Matt,

   from what i know ActAct/ICMA is used for bond accrual and yield (and other bond analytics) calculation. What I also saw is that spread quotations over a reference curve (e.g. a swap curve) for a (single) bond are following the bond's day count and yield convention in the sense that the reference curve is rebootstrapped using the bond's ActAct/ICMA day count convention (and also bond yield compounding) for the stripped zero yields. However in my understanding this is clearly dependent on the single bond to be valued and not applicable to a situation where a zero curve or a spread term structure over a reference curve is built from several bonds, as in your case.

So my next question would be how exactly your zero curve was calculated (what you call precalculated curve below). I could imagine that some instrument independent day counter was used such as ActAct/ISDA) or Act365(Fixed). Do you have any details on that ?

kind regards
   Peter


"Knox, Matt" <[hidden email]> writes:

> Thanks Peter. The situation is as follows:
>
> I have a pre-calculated zero curve which was boot strapped from
> government of Canada bonds. According to this document
> http://iiac.ca/wp-content/uploads/Canadian-Conventions-in-FI-Markets.p
> df , the day count convention for these bonds would be
> ActualActual(Bond) if I am understanding it correctly - see footnote
> at bottom of page 6 of that document. I want to use this curve to
> calculate some shocks on a bond portfolio, as well as a stream of cash
> flows (representing pension liabilities). My thinking was that when I
> construct the zero curve, I should match the day count convention of
> the bonds that were used to build it. Furthermore, for apples to
> apples comparison with the liabilities, I should use the same day
> count on the liability cash flows. However, due to the spacing of the
> data points in the pre-calculated curve, I would have to pre-adjust
> the curve to pass it into the ZeroCurve constructor if I am to use the
> ActualActual(Bond) day count convention.
>
> So my options seem to be: adjust the curve, or pick another day count convention that is "good enough".
>
> Does my thinking make sense here? Or am I going about this the wrong way? Thanks for the reply, appreciate any insight you can offer.
>
> - Matt
>
> -----Original Message-----
> From: Peter Caspers [mailto:[hidden email]]
> Sent: November 16, 2013 3:02 PM
> To: Knox, Matt
> Cc: '[hidden email]'
> Subject: Re: [Quantlib-users] problem with ZeroCurve and
> ActualActual(Bond) day count
>
> The dates are actually different, but the year fraction is the same
> for groups of several of dates under ActualActual/ICMA because no
> reference period is specified in TermStructure::timeFromReference(),
> therefore it is set equal to the period itself, therefore (largely)
> yearfractions of the form n/12 are produced. Since the spacing between
> your dates is only 10 days, more than one date can (and does) produce
> the same year fraction.
>
> So I guess technically the behaviour is expected (also, with a meaningful message thrown).
>
> The question is, what do you want to achieve exactly ?
>
> best regards
>    Peter
>
>
> "Knox, Matt" <[hidden email]> writes:
>
>> I am trying to construct zero curves using the ZeroCurve class (using
>> the Python wrappers), and I seem to run into problems when using the
>> ActualActual(Bond) day count convention. It thinks that different
>> input dates are actually the same date.
>>
>> The best way I can explain this is with an example. Consider the
>> following code:
>>
>> #.....................................................................
>> import QuantLib as ql
>> import traceback
>>
>> start_date = ql.Date(30,9,2013)
>>
>> # 50 years of data points spaced 10 days apart dates = [(start_date +
>> x * 10) for x in range(365 * 5)] rates = [0.02 for _ in dates]
>>
>> for daycount, description in [
>>     (ql.ActualActual(ql.ActualActual.Bond), "ActualActual(Bond)"),
>>     (ql.ActualActual(ql.ActualActual.ISDA), "ActualActual(ISDA)"),
>>     (ql.Actual360(), "Actual360()"),
>>     (ql.Thirty360(), "Thirty360()"),
>> ]:
>>     try:
>>         ql.ZeroCurve(dates, rates, daycount)
>>         print "success: %s" % description
>>     except:
>>         print "failure: %s" % description
>>         print traceback.format_exc()
>> # and the output....
>> failure: ActualActual(Bond)
>> Traceback (most recent call last):
>>   File "foobar.py", line 47, in <module>
>>     ql.ZeroCurve(dates, rates, daycount)
>>   File "C:\analytics\ext\python27\lib\site-packages\QuantLib\
>> QuantLib.py", line 10028, in __init__
>>     this = _QuantLib.new_ZeroCurve(*args)
>> RuntimeError: two dates correspond to the same time under this
>> curve's day count convention
>>
>> success: ActualActual(ISDA)
>> success: Actual360()
>> success: Thirty360()
>>
>> #....................................
>> This is using Python 2.7 and QuantLib 1.3
>>
>> Any idea what is going on?
>>
>> Any help would be greatly appreciated. Thanks!
>>
>> - Matt Knox
>>
>>
>>
>> NOTICE: Confidential message which may be privileged. Unauthorized
>> use/disclosure prohibited. If received in error, please go to
>> www.td.com/legal for instructions.
>> AVIS : Message confidentiel dont le contenu peut être privilégié.
>> Utilisation/divulgation interdites sans permission. Si reçu par
>> erreur, prière d'aller au www.td.com/francais/avis_juridique pour des
>> instructions.
>>
>>
>>
>> ---------------------------------------------------------------------
>> -
>> -------- DreamFactory - Open Source REST & JSON Services for HTML5 &
>> Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and
>> External API Access Free app hosting. Or install the open source
>> package on any LAMP server.
>> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
>> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.
>> c lktrk _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> NOTICE: Confidential message which may be privileged. Unauthorized use/disclosure prohibited. If received in error, please go to www.td.com/legal for instructions.
> AVIS : Message confidentiel dont le contenu peut être privilégié. Utilisation/divulgation interdites sans permission. Si reçu par erreur, prière d'aller au www.td.com/francais/avis_juridique pour des instructions.


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users