Skip to content

Commit

Permalink
Correct Thailand calendar for 2019-2024 (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio authored Dec 18, 2023
2 parents 2e8231b + 66de7b5 commit 7ec4fbb
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 22 deletions.
97 changes: 78 additions & 19 deletions ql/time/calendars/thailand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/*
Copyright (C) 2018 Matthias Groncki
Copyright (C) 2023 Skandinaviska Enskilda Banken AB (publ)
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
Expand Down Expand Up @@ -35,29 +36,34 @@ namespace QuantLib {

if (isWeekend(w)
// New Year's Day
|| ((d == 1 || (d==3 && w==Monday)) && m == January)
|| ((d == 1 || (d == 3 && w == Monday)) && m == January)
// Chakri Memorial Day
|| ((d == 6 || ((d==7 || d==8) && w==Monday)) && m == April)
// Songkran Festival
|| ((d == 13 || d == 14 || d == 15) && m == April)
// Songkran Festival obersvence (usually not more then 1 holiday will be replaced)
|| (d == 16 && (w == Monday || w == Tuesday) && m == April)
|| ((d == 6 || ((d == 7 || d == 8) && w == Monday)) && m == April)
// Songkran Festival (was cancelled in 2020 due to the Covid-19 Pandamic)
|| ((d == 13 || d == 14 || d == 15) && m == April && y != 2020)
// Substitution Songkran Festival, usually not more than 5 days in total (was cancelled
// in 2020 due to the Covid-19 Pandamic)
|| (d == 16 && (w == Monday || w == Tuesday) && m == April && y != 2020)
// Labor Day
|| ((d == 1 || ((d==2 || d==3) && w==Monday)) && m == May)
// H.M. the King's Birthday
|| ((d == 28 || ((d==29 || d==30) && w==Monday)) && m == July && y >= 2017)
// H.M. the Queen's Birthday
|| ((d == 12 || ((d==13 || d==14) && w==Monday)) && m == August)
// H.M. King Bhumibol Adulyadej Memorial Day
|| ((d == 13 || ((d==14 || d==15) && w==Monday)) && m == October && y >= 2017)
// H.M. King Bhumibol Adulyadej's Birthday
|| ((d == 5 || ((d==6 || d==7) && w==Monday)) && m == December)
|| ((d == 1 || ((d == 2 || d == 3) && w == Monday)) && m == May)
// Coronation Day
|| ((d == 4 || ((d == 5 || d == 6) && w == Monday)) && m == May && y >= 2019)
// H.M.Queen Suthida Bajrasudhabimalalakshana’s Birthday
|| ((d == 03 || ((d == 04 || d == 05) && w == Monday)) && m == June && y >= 2019)
// H.M. King Maha Vajiralongkorn Phra Vajiraklaochaoyuhua’s Birthday
|| ((d == 28 || ((d == 29 || d == 30) && w == Monday)) && m == July && y >= 2017)
// ​H.M. Queen Sirikit The Queen Mother’s Birthday / Mother’s Day
|| ((d == 12 || ((d == 13 || d == 14) && w == Monday)) && m == August)
// H.M. King Bhumibol Adulyadej The Great Memorial Day
|| ((d == 13 || ((d == 14 || d == 15) && w == Monday)) && m == October && y >= 2017)
// Chulalongkorn Day
|| ((d == 23 || ((d == 24 || d == 25) && w == Monday)) && m == October && y != 2021) // Moved 2021, see below
// H.M. King Bhumibol Adulyadej The Great’s Birthday/ National Day / Father’s Day
|| ((d == 5 || ((d == 6 || d == 7) && w == Monday)) && m == December)
// Constitution Day
|| ((d == 10 || ((d==11 || d==12) && w==Monday)) && m == December)
|| ((d == 10 || ((d == 11 || d == 12) && w == Monday)) && m == December)
// New Year’s Eve
|| (d == 31 && m == December)
// New Year’s Eve Observence
|| ((d == 1 || d==2) && w == Monday && m == January)
|| ((d == 31 && m == December) || (d == 2 && w == Monday && m == January && y != 2024)) // Moved 2024
)
return false;

Expand Down Expand Up @@ -236,6 +242,59 @@ namespace QuantLib {
))
return false;

if ((y == 2019) && ((d == 19 && m == February) // Makha Bucha Day
|| (d == 6 && m == May) // Special Holiday
|| (d == 20 && m == May) // Wisakha Bucha Day
|| (d == 16 && m == July) // Asarnha Bucha Day
))
return false;

if ((y == 2020) && ((d == 10 && m == February) // Makha Bucha Day
|| (d == 6 && m == May) // Wisakha Bucha Day
|| (d == 6 && m == July) // Asarnha Bucha Day
|| (d == 27 && m == July) // Substitution for Songkran Festival
|| (d == 4 && m == September) // Substitution for Songkran Festival
|| (d == 7 && m == September) // Substitution for Songkran Festival
|| (d == 11 && m == December) // Special Holiday
))
return false;

if ((y == 2021) && ((d == 12 && m == February) // Special Holiday
|| (d == 26 && m == February) // Makha Bucha Day
|| (d == 26 && m == May) // Wisakha Bucha Day
|| (d == 26 && m == July) // Substitution for Asarnha Bucha Day (Saturday 24th July 2021)
|| (d == 24 && m == September) // Special Holiday
|| (d == 22 && m == October) // ​Substitution for Chulalongkorn Day
))
return false;

if ((y == 2022) && ((d == 16 && m == February) // Makha Bucha Day
|| (d == 16 && m == May) // Substitution for Wisakha Bucha Day (Sunday 15th May 2022)
|| (d == 13 && m == July) // Asarnha Bucha Day
|| (d == 29 && m == July) // Additional special holiday (added)
|| (d == 14 && m == October) // Additional special holiday (added)
|| (d == 24 && m == October) // ​Substitution for Chulalongkorn Day (Sunday 23rd October 2022)
))
return false;

if ((y == 2023) && ((d == 6 && m == March) // Makha Bucha Day
|| (d == 5 && m == May) // Additional special holiday (added)
|| (d == 5 && m == June) // Substitution for H.M. Queen's birthday and Wisakha Bucha Day (Saturday 3rd June 2022)
|| (d == 1 && m == August) // Asarnha Bucha Day
|| (d == 23 && m == October) // Chulalongkorn Day
|| (d == 29 && m == December) // Substitution for New Year’s Eve (Sunday 31st December 2023) (added)
))
return false;

if ((y == 2024) && ((d == 26 && m == February) // Substitution for Makha Bucha Day (Saturday 24th February 2024)
|| (d == 8 && m == April) // Substitution for Chakri Memorial Day (Saturday 6th April 2024)
|| (d == 6 && m == May) // Substitution for Coronation Day (Saturday 4th May 2024)
|| (d == 22 && m == May) // Wisakha Bucha Day
|| (d == 22 && m == July) // Substitution for Asarnha Bucha Day (Saturday 20th July 2024)
|| (d == 23 && m == October) // Chulalongkorn Day
))
return false;

return true;
}

Expand Down
7 changes: 4 additions & 3 deletions ql/time/calendars/thailand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/*
Copyright (C) 2018 Matthias Groncki
Copyright (C) 2023 Skandinaviska Enskilda Banken AB (publ)
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
Expand Down Expand Up @@ -31,12 +32,12 @@ namespace QuantLib {
//! %Thailand calendars
/*! Holidays for the Thailand exchange
Holidays observed by financial institutions (not to be confused with bank holidays in the United Kingdom) are regulated by the Bank of Thailand.
If a holiday fall on a weekend the government will annouce a replacement day (usally the following monday).
If a holiday fall on a weekend the government will announce a replacement day (usually the following Monday).
Sometimes the government add one or two extra holidays in a year.
(data from
https://www.bot.or.th/English/FinancialInstitutions/FIholiday/Pages/2018.aspx:
https://www.bot.or.th/en/financial-institutions-holiday.html:
Fixed holidays
<ul>
<li>Saturdays</li>
Expand All @@ -53,7 +54,7 @@ namespace QuantLib {
</ul>
Other holidays for which no rule is given
(data available for 2000-2018 with some years missing)
(data available for 2000-2024 with some years missing)
<ul>
<li>Makha Bucha Day</li>
<li>Wisakha Bucha Day</li>
Expand Down

0 comments on commit 7ec4fbb

Please sign in to comment.