question about daycount (a/a)

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

question about daycount (a/a)

Jeff Yu-3

Hi, I run into an issue when using the actualactual daycount:

 

ActualAcutal      dayCounter;

 

Date     d1 = Date(1,March,2000);

Date     d2 = Date(3,March,2000);

 

Time z = dayCounter.yearFraction(d1, d2);

 

An exception is thrown because the month between d1 and d2 is zero.

 

I notice that the exception would be thrown unless d1 and d2 is equal or greater than 15 days.  …. Also, the z is in question unless the refPeriodStart and refPeriodEnd are given.

 

Any idea what is going on?  A possible bug or I might have missed something?

 

Cheers,

Jeff

Reply | Threaded
Open this post in threaded view
|

RE: question about daycount (a/a)

Jeff Yu-3

Here is the brief background information how I ran into this problem:

 

I was trying to get the forward rate between two days, which are very close to one another.

 

Boost::shared_ptr<TermStructure> fwd (new FlatForward(d1, d1, 0.05, ActualActual() );

 

…..

 

Rate = fwd->forward(d3, d4)                    // d4 – d3 = 3

 

Exception is thrown.                               // if d4 – d3 < 15

 

… Any input would be greatly appreciated.

 

Jeff

 

 

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Jeff Yu
Sent:
Tuesday, August 17, 2004 7:42 PM
To: 'QuantLib users'
Subject: [Quantlib-users] question about daycount (a/a)

 

Hi, I run into an issue when using the actualactual daycount:

 

ActualAcutal      dayCounter;

 

Date     d1 = Date(1,March,2000);

Date     d2 = Date(3,March,2000);

 

Time z = dayCounter.yearFraction(d1, d2);

 

An exception is thrown because the month between d1 and d2 is zero.

 

I notice that the exception would be thrown unless d1 and d2 is equal or greater than 15 days.  …. Also, the z is in question unless the refPeriodStart and refPeriodEnd are given.

 

Any idea what is going on?  A possible bug or I might have missed something?

 

Cheers,

Jeff

Reply | Threaded
Open this post in threaded view
|

RE: question about daycount (a/a)

Daniele De Francesco-2
In reply to this post by Jeff Yu-3
Hi Jeff

It's because the ActualActual daycounter needs a period to be able
to work correctly.
If you call the convention "Actual/Actual in period" it suddenly makes more
sense (for me at least)...
 
Basically the convention says that given a period, you are calculating the
*period* fraction and then scaling that to the whole year. That is useful in
case of coupon payments, where the period is for example 6 months.
To take an example, imagine that your real period was from 20 May 2004 to
20 November 2004, and you wanted to get the actual/actual year fraction
between 20 May 2004 and 26 July 2004.
If you look at the code, it first determines that your period is 6 months,
and the total actual days in the period are, let's say 183 (I didn't
actually count, forgive me). Then you do actual/actual in period, which is
67/183 and you scale back by the fact that there are two periods in a year
so the final formula is 67/183 * 2

For your code to work, you should either provide a reference period (which
should be a whole number of months) or the function will try to determine it
from your accrual start and end dates.
When your days are less than 15 days from each other, the approximate number
of months in your period becomes 0 and you get the exception.

So.... Using actual actual only makes sense if you are using it with a
reference period and that's why those two extra arguments are there.  In
your case, I suspect those dates are part of a coupon payment period, and
you should use those as a reference.

Hope this helps,
-Daniele

P.S.: I have actually cut and pasted most of my answer from a previous post
of mine on the same topic. I would recommend seraching the archive, since a
lot of questions have already been answered. In this case searching for
"actual actual problems" would have probably gotten you the answer....

-----Original Message-----
From: Jeff Yu [mailto:[hidden email]]
Sent: Tuesday, August 17, 2004 9:12 PM
To: 'QuantLib users'
Subject: RE: [Quantlib-users] question about daycount (a/a)


Here is the brief background information how I ran into this problem:
 
I was trying to get the forward rate between two days, which are very close
to one another.
 
Boost::shared_ptr<TermStructure> fwd (new FlatForward(d1, d1, 0.05,
ActualActual() );
 
.....
 
Rate = fwd->forward(d3, d4)                    // d4 - d3 = 3
 
Exception is thrown.                               // if d4 - d3 < 15
 
... Any input would be greatly appreciated.
 
Jeff
 
 
 
-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Jeff Yu
Sent: Tuesday, August 17, 2004 7:42 PM
To: 'QuantLib users'
Subject: [Quantlib-users] question about daycount (a/a)
 
Hi, I run into an issue when using the actualactual daycount:
 
ActualAcutal      dayCounter;
 
Date     d1 = Date(1,March,2000);
Date     d2 = Date(3,March,2000);
 
Time z = dayCounter.yearFraction(d1, d2);
 
An exception is thrown because the month between d1 and d2 is zero.
 
I notice that the exception would be thrown unless d1 and d2 is equal or
greater than 15 days.  .... Also, the z is in question unless the
refPeriodStart and refPeriodEnd are given.
 
Any idea what is going on?  A possible bug or I might have missed something?
 
Cheers,
Jeff


Reply | Threaded
Open this post in threaded view
|

RE: question about daycount (a/a)

Jeff Yu-3
I agree.  After using Actual365, things are back to normal.

Thanks,

Jeff

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Daniele
De Francesco
Sent: Wednesday, August 18, 2004 9:43 AM
To: '[hidden email]'; 'QuantLib users'
Subject: RE: [Quantlib-users] question about daycount (a/a)

Hi Jeff

It's because the ActualActual daycounter needs a period to be able
to work correctly.
If you call the convention "Actual/Actual in period" it suddenly makes
more
sense (for me at least)...
 
Basically the convention says that given a period, you are calculating
the
*period* fraction and then scaling that to the whole year. That is
useful in
case of coupon payments, where the period is for example 6 months.
To take an example, imagine that your real period was from 20 May 2004
to
20 November 2004, and you wanted to get the actual/actual year fraction
between 20 May 2004 and 26 July 2004.
If you look at the code, it first determines that your period is 6
months,
and the total actual days in the period are, let's say 183 (I didn't
actually count, forgive me). Then you do actual/actual in period, which
is
67/183 and you scale back by the fact that there are two periods in a
year
so the final formula is 67/183 * 2

For your code to work, you should either provide a reference period
(which
should be a whole number of months) or the function will try to
determine it
from your accrual start and end dates.
When your days are less than 15 days from each other, the approximate
number
of months in your period becomes 0 and you get the exception.

So.... Using actual actual only makes sense if you are using it with a
reference period and that's why those two extra arguments are there.  In
your case, I suspect those dates are part of a coupon payment period,
and
you should use those as a reference.

Hope this helps,
-Daniele

P.S.: I have actually cut and pasted most of my answer from a previous
post
of mine on the same topic. I would recommend seraching the archive,
since a
lot of questions have already been answered. In this case searching for
"actual actual problems" would have probably gotten you the answer....

-----Original Message-----
From: Jeff Yu [mailto:[hidden email]]
Sent: Tuesday, August 17, 2004 9:12 PM
To: 'QuantLib users'
Subject: RE: [Quantlib-users] question about daycount (a/a)


Here is the brief background information how I ran into this problem:
 
I was trying to get the forward rate between two days, which are very
close
to one another.
 
Boost::shared_ptr<TermStructure> fwd (new FlatForward(d1, d1, 0.05,
ActualActual() );
 
.....
 
Rate = fwd->forward(d3, d4)                    // d4 - d3 = 3
 
Exception is thrown.                               // if d4 - d3 < 15
 
... Any input would be greatly appreciated.
 
Jeff
 
 
 
-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Jeff Yu
Sent: Tuesday, August 17, 2004 7:42 PM
To: 'QuantLib users'
Subject: [Quantlib-users] question about daycount (a/a)
 
Hi, I run into an issue when using the actualactual daycount:
 
ActualAcutal      dayCounter;
 
Date     d1 = Date(1,March,2000);
Date     d2 = Date(3,March,2000);
 
Time z = dayCounter.yearFraction(d1, d2);
 
An exception is thrown because the month between d1 and d2 is zero.
 
I notice that the exception would be thrown unless d1 and d2 is equal or
greater than 15 days.  .... Also, the z is in question unless the
refPeriodStart and refPeriodEnd are given.
 
Any idea what is going on?  A possible bug or I might have missed
something?
 
Cheers,
Jeff


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



Reply | Threaded
Open this post in threaded view
|

Re: question about daycount (a/a)

Luigi Ballabio-2
On 2004.08.19 00:52, Jeff Yu wrote:
> I agree.  After using Actual365, things are back to normal.

Also, ActualActual implements three conventions, of which one is used  
by default. You might want to check the other two.

Later,
        Luigi