Hi!
I wrote ql/Calendars/tokyo.cpp fix of equinox. This patch calculates astronomical equinox date not official equinox date. But astronomical equinox date is a good estimate of official equinox date. ==== #include <ql/Calendars/tokyo.hpp> namespace QuantLib { namespace Calendars { bool Tokyo::TokCalendarImpl::isBusinessDay(const Date& date) const { Weekday w = date.weekday(); Day d = date.dayOfMonth(); Month m = date.month(); Year y = date.year(); const double exact_vernal_equinox_time = 20.69115; // at 2000 const double exact_autumnal_equinox_time = 23.09; const double diff_per_year = 0.242194; double moving_amount = (y-2000)*diff_per_year; int number_of_leap_year = (y-2000)/4+(y-2000)/100-(y-2000)/400; const int ve = // vernal_equinox_day int(exact_vernal_equinox_time + moving_amount - number_of_leap_year); const int ae = // autumnal_equinox_day int(exact_autumnal_equinox_time + moving_amount - number_of_leap_year); if ((w == Saturday || w == Sunday) // New Year's Day || (d == 1 && m == January) // Bank Holiday || (d == 2 && m == January) // Bank Holiday || (d == 3 && m == January) // Coming of Age Day (2nd Monday in January) || (w == Monday && (d >= 8 && d <= 14) && m == January) // National Foundation Day || ((d == 11 || (d == 12 && w == Monday)) && m == February) // Vernal Equinox || ((d == ve || (d == (ve+1) && w == Monday)) && m == March) // Greenery Day || ((d == 29 || (d == 30 && w == Monday)) && m == April) // Constitution Memorial Day || (d == 3 && m == May) // Holiday for a Nation || (d == 4 && m == May) // Children's Day || ((d == 5 || (d == 6 && w == Monday)) && m == May) // Marine Day || ((d == 20 || (d == 21 && w == Monday)) && m == July) // Respect for the Aged Day || ((d == 15 || (d == 16 && w == Monday)) && m == September) // Autumnal Equinox || ((d == ae || (d == (ae+1) && w == Monday)) && m == September) // Health and Sports Day (2nd Monday in October) || (w == Monday && (d >= 8 && d <= 14) && m == October) // National Culture Day || ((d == 3 || (d == 4 && w == Monday)) && m == November) // Labor Thanksgiving Day || ((d == 23 || (d == 24 && w == Monday)) && m == November) // Emperor's Birthday || ((d == 23 || (d == 24 && w == Monday)) && m == December) // Bank Holiday || (d == 31 && m == December)) return false; return true; } } } |
At 01:06 AM 1/27/03 +0900, KAWANISHI Tomoya wrote:
>I wrote ql/Calendars/tokyo.cpp fix of equinox. Greetings, thanks for the patch. I'm adding it to the cvs repository, so that it makes it into the release after next (next release is already frozen and should come out in a few days.) Did you have a look at the other Tokyo holidays? Are they correct? Thank you, Luigi |
Hi, there.
On Mon, 27 Jan 2003 09:37:24 +0100 Luigi Ballabio <[hidden email]> wrote: > Did you have a look at the other Tokyo holidays? Are they correct? I checked and fixed other Tokyo holidays, Dates of the hollidays , Marine day and Respect for the aged day has been changed since January 1st 2003. "Marine day" is third Monday July and "Respect for the Aged Day" is third Monday June since 2003. Until 2000, "Coming of Age day" and "Health and Sports Day" was not the day on the program but 15th January and 10th October respectively. "Marine day" is holiday since 1996. 23rd December is "Emperor's birthday" since 1988. So the code should be as follows. Please mail me when you have any questions. === #include <ql/Calendars/tokyo.hpp> namespace QuantLib { namespace Calendars { bool Tokyo::TokCalendarImpl::isBusinessDay(const Date& date) const { Weekday w = date.weekday(); Day d = date.dayOfMonth(); Month m = date.month(); Year y = date.year(); const double exact_vernal_equinox_time = 20.69115; // at 2000 const double exact_autumnal_equinox_time = 23.09; const double diff_per_year = 0.242194; double moving_amount = (y-2000)*diff_per_year; int number_of_leap_year = (y-2000)/4+(y-2000)/100-(y-2000)/400; const int ve = // vernal_equinox_day int(exact_vernal_equinox_time + moving_amount - number_of_leap_year); const int ae = // autumnal_equinox_day int(exact_autumnal_equinox_time + moving_amount - number_of_leap_year); if ((w == Saturday || w == Sunday) // New Year's Day || (d == 1 && m == January) // Bank Holiday || (d == 2 && m == January) // Bank Holiday || (d == 3 && m == January) // Coming of Age Day (2nd Monday in January) || ((d == 15 || (d = 16 && w == Monday)) && m == January && y <= 1999) || (w == Monday && (d >= 8 && d <= 14) && m == January && y >= 2000) // National Foundation Day || ((d == 11 || (d == 12 && w == Monday)) && m == February) // Vernal Equinox || ((d == ve || (d == (ve+1) && w == Monday)) && m == March) // Greenery Day || ((d == 29 || (d == 30 && w == Monday)) && m == April) // Constitution Memorial Day || (d == 3 && m == May) // Holiday for a Nation || (d == 4 && m == May) // Children's Day || ((d == 5 || (d == 6 && w == Monday)) && m == May) // Marine Day || ((d == 20 || (d == 21 && w == Monday)) && m == July && (y >= 1996 && y <= 2002)) || (w == Monday && (d >= 15 && d<= 21) && m == July && y >= 2003) // Respect for the Aged Day || ((d == 15 || (d == 16 && w == Monday)) && m == September && y <= 2002) || (w == Monday && (d >= 15 && d<= 21) && m == September && y >= 2003) // Autumnal Equinox || ((d == ae || (d == (ae+1) && w == Monday)) && m == September) // Holiday for a Nation // Between "Respect for the aged day" and "Autumnal Equinox" || (w == Tuesday && d+1 == ae && m == September && y >= 2003) // Health and Sports Day (2nd Monday in October) || ((d == 10 || (d == 11 && w == Monday)) && m == October && y <= 1999) || (w == Monday && (d >= 8 && d <= 14) && m == October && y >= 2000) // National Culture Day || ((d == 3 || (d == 4 && w == Monday)) && m == November) // Labor Thanksgiving Day || ((d == 23 || (d == 24 && w == Monday)) && m == November) // Emperor's Birthday || ((d == 23 || (d == 24 && w == Monday)) && m == December && y >= 1989) // Bank Holiday || (d == 31 && m == December)) return false; return true; } } } |
At 12:47 AM 1/28/03 +0900, KAWANISHI Tomoya wrote:
>I checked and fixed other Tokyo holidays, Thanks, I integrated the fixes and the one-shot holidays in CVS. Bye, Luigi P.S. I'm adding you to the QuantLib contributors, but I must confess my ignorance of Japanese conventions. Is Kawanishi or Tomoya your first name? |
Hi there.
> P.S. I'm adding you to the QuantLib contributors, but I must confess my > ignorance of Japanese conventions. Is Kawanishi or Tomoya your first name? My first name is Tomoya. And my surname is Kawanishi. Thanks for adding me to QuantLib contributors list. --- KAWANISHI Tomoya [hidden email] Tomoya is first name |
In reply to this post by KAWANISHI Tomoya
Just in case anybody is using the attached code directly:
> bool Tokyo::TokCalendarImpl::isBusinessDay(const Date& date) const { [...] > // Coming of Age Day (2nd Monday in January) > || ((d == 15 || (d = 16 && w == Monday)) && m == must be: d == 16 The CVS version is correct. Jens. |
In reply to this post by KAWANISHI Tomoya
Hi.
On Tue, 28 Jan 2003 12:05:02 +0100 "Jens Thiel" <[hidden email]> wrote: > Tomoya, > > was the first "Emperor's birthday" in 1988 (your description) or 1989 (your > code)? Code is correct. First "Emperor's birthday" was in 1989. And I found one mistake on holiday for a nation. > || (w == Tuesday && d+1 == ae && m == September && y >= 2003) This code should be || (w == Tuesday && d+1 == ae && d >= 16 && d <= 22 && m == September && y >= 2003) There is a rule that a day between legal holidays is legal holiday. Please make the CVS correct. --- KAWANISHI Tomoya [hidden email] KAWANISHI is surname. Tomoya is first name. > > Jens. > > > 23rd December is "Emperor's birthday" since 1988. > [...] > > > > // Emperor's Birthday > > || ((d == 23 || (d == 24 && w == Monday)) && m == December && y >= 1989) |
Free forum by Nabble | Edit this page |