From edba144d18939ee8fe493bda8b739ccf97ebaa16 Mon Sep 17 00:00:00 2001 From: "jonghee.lee" Date: Tue, 20 Jun 2023 17:10:28 +0900 Subject: [PATCH 1/8] apply substitute holiday --- ql/time/calendars/southkorea.cpp | 118 ++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 19 deletions(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index 3cb6b44a964..b1c709e1346 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -55,6 +55,20 @@ namespace QuantLib { Month m = date.month(); Year y = date.year(); + // Substitute holiday of Independence Day + // Substitute holiday of Children's Day + // Substitute holiday of National Foundation Day + // Substitute holiday of Hangul Proclamation of Korea + // Substitute holiday of Christmas Day + if ((w == Monday && (d == 2 || d == 3) && m == March && y > 2021) || + (w == Monday && (d == 6 || d == 7) && m == May && y > 2013) || + (w == Monday && (d == 16 || d == 17) && m == August && y > 2020) || + (w == Monday && (d == 4 || d == 5) && m == October && y > 2020) || + (w == Monday && (d == 10 || d == 11) && m == October && y > 2020) || + (w == Monday && (d == 26 || d == 27) && m == December && y > 2022)) { + return false; + } + if (isWeekend(w) // New Year's Day || (d == 1 && m == January) @@ -98,18 +112,41 @@ namespace QuantLib { || ((d == 4 || d == 5 || d == 6) && m == February && y == 2019) || ((d >= 24 && d <= 27) && m == January && y == 2020) || ((d == 11 || d == 12 || d == 13) && m == February && y == 2021) - || (((d == 31 && m == January) || ((d == 1 || d == 2) + || (((d == 31 && m == January) || ((d == 1|| d == 2) && m == February)) && y == 2022) - || ((d == 21 || d == 22 || d == 23) && m == January && y == 2023) - || ((d == 9 || d == 10 || d == 11) && m == February && y == 2024) - || ((d == 28 || d == 29 || d == 30) && m == January && y == 2025) - || ((d == 16 || d == 17 || d == 18) && m == February && y == 2026) - || ((d == 5 || d == 6 || d == 7) && m == February && y == 2027) - || ((d == 25 || d == 26 || d == 27) && m == January && y == 2028) - || ((d == 12 || d == 13 || d == 14) && m == February && y == 2029) - || ((d == 2 || d == 3 || d == 4) && m == February && y == 2030) - || ((d == 22 || d == 23 || d == 24) && m == January && y == 2031) - || ((d == 10 || d == 11 || d == 12) && m == February && y == 2032) + || ((d == 23 || d == 24) && m == January && y == 2023) + || ((d >= 9 && d <= 12) && m == February && y == 2024) + || ((d == 28 || d == 29 || d == 30) && m == January && y == 2025) + || ((d == 16 || d == 17 || d == 18) && m == February && y == 2026) + || ((d == 8 || d == 9) && m == February && y == 2027) + || ((d == 26 || d == 27 || d == 28) && m == January && y == 2028) + || ((d == 12 || d == 13 || d == 14) && m == February && y == 2029) + || ((d == 4 || d == 5) && m == February && y == 2030) + || ((d == 22 || d == 23 || d == 24) && m == January && y == 2031) + || ((d == 10 || d == 11 || d == 12) && m == February && y == 2032) + || (((d == 31 && m == January) || ((d == 1|| d == 2) + && m == February)) && y == 2033) + || ((d == 20 || d == 21) && m == February && y == 2034) + || ((d == 7 || d == 8 || d == 9) && m == February && y == 2035) + || ((d == 28 || d == 29 || d == 30) && m == January && y == 2036) + || ((d == 16 || d == 17) && m == February && y == 2037) + || ((d == 3 || d == 4 || d == 5) && m == February && y == 2038) + || ((d == 24 || d == 25 || d == 26) && m == January && y == 2039) + || ((d == 13 || d == 14) && m == February && y == 2040) + || (((d == 31 && m == January) || ((d == 1|| d == 2) + && m == February)) && y == 2041) + || ((d == 21 || d == 22 || d == 23) && m == January && y == 2042) + || ((d == 9 || d == 10 || d == 11) && m == February && y == 2043) + || ((((d == 29|| d == 30|| d == 31) && m == January) + || (d == 1 && m == February)) && y == 2044) + || ((d == 16 || d == 17 || d == 18) && m == February && y == 2045) + || ((d == 5 || d == 6 || d == 7) && m == February && y == 2046) + || ((d >= 25 && d <= 28) && m == January && y == 2047) + || ((d == 13 || d == 14 || d == 15) && m == February && y == 2048) + || ((d == 1 || d == 2 || d == 3) && m == February && y == 2049) + || ((d == 24 || d == 25) && m == January && y == 2050) + || ((d == 24 || d == 25) && m == January && y == 2051) + || ((d == 24 || d == 25) && m == January && y == 2052) // Election Days || (d == 15 && m == April && y == 2004) // National Assembly @@ -147,16 +184,37 @@ namespace QuantLib { || (d == 30 && m == April && y == 2020) || (d == 19 && m == May && y == 2021) || (d == 8 && m == May && y == 2022) - || (d == 26 && m == May && y == 2023) + || (d == 29 && m == May && y == 2023) // Substitute holiday || (d == 15 && m == May && y == 2024) || (d == 5 && m == May && y == 2025) - || (d == 24 && m == May && y == 2026) + || (d == 25 && m == May && y == 2026) // Substitute holiday || (d == 13 && m == May && y == 2027) || (d == 2 && m == May && y == 2028) - || (d == 20 && m == May && y == 2029) + || (d == 21 && m == May && y == 2029) // Substitute holiday || (d == 9 && m == May && y == 2030) || (d == 28 && m == May && y == 2031) - || (d == 16 && m == May && y == 2032) + || (d == 17 && m == May && y == 2032) // Substitute holiday + || (d == 6 && m == May && y == 2033) + || (d == 25 && m == May && y == 2034) + || (d == 15 && m == May && y == 2035) + || (d == 5 && m == May && y == 2036) // Substitute holiday + || (d == 22 && m == May && y == 2037) + || (d == 11 && m == May && y == 2038) + || (d == 2 && m == May && y == 2039) // Substitute holiday + || (d == 18 && m == May && y == 2040) + || (d == 7 && m == May && y == 2041) + || (d == 26 && m == May && y == 2042) + || (d == 18 && m == May && y == 2043) // Substitute holiday + || (d == 5 && m == May && y == 2044) + || (d == 24 && m == May && y == 2045) + || (d == 14 && m == May && y == 2046) // Substitute holiday + || (d == 2 && m == May && y == 2047) + || (d == 20 && m == May && y == 2048) + || (d == 10 && m == May && y == 2049) // Substitute holiday + || (d == 30 && m == May && y == 2050) // Substitute holiday + || (d == 30 && m == May && y == 2051) // Substitute holiday + || (d == 30 && m == May && y == 2052) // Substitute holiday + || (d == 30 && m == May && y == 2053) // Substitute holiday // Special holiday: 70 years from Independence Day || (d == 14 && m == August && y == 2015) @@ -184,17 +242,39 @@ namespace QuantLib { && m == October)) && y == 2020) || ((d == 20 || d == 21 || d == 22) && m == September && y == 2021) || ((d == 9 || d == 10 || d == 11) && m == September && y == 2022) + || ((d >= 9 && d <= 12) && m == September && y == 2022) || ((d == 28 || d == 29 || d == 30) && m == September && y == 2023) || ((d == 16 || d == 17 || d == 18) && m == September && y == 2024) - || ((d == 5 || d == 6 || d == 7) && m == October && y == 2025) + || ((d == 6 || d == 7 || d == 8) && m == October && y == 2025) || ((d == 24 || d == 25 || d == 26) && m == September && y == 2026) || ((d == 14 || d == 15 || d == 16) && m == September && y == 2027) - || ((d == 2 || d == 3 || d == 4) && m == October && y == 2028) - || ((d == 21 || d == 22 || d == 23) && m == September && y == 2029) + || ((d >= 2 && d <= 5) && m == October && y == 2028) + || ((d >= 21 && d <= 24) && m == September && y == 2029) || ((d == 11 || d == 12 || d == 13) && m == September && y == 2030) || (((d == 30 && m == September) || ((d == 1 || d == 2) && m == October)) && y == 2031) - || ((d == 18 || d == 19 || d == 20) && m == September && y == 2032) + || ((d == 20 || d == 21) && m == September && y == 2032) + || ((d == 7 || d == 8 || d == 9) && m == September && y == 2033) + || ((d == 26 || d == 27 || d == 28) && m == September && y == 2034) + || ((d == 17 || d == 18) && m == September && y == 2035) + || ((d >= 3 && d <= 6) && m == October && y == 2036) + || ((d == 23 || d == 24 || d == 25) && m == September && y == 2037) + || ((d == 13 || d == 14 || d == 15) && m == September && y == 2038) + || ((d == 3 || d == 4 || d == 5) && m == October && y == 2039) + || ((d == 20 || d == 21 || d == 22) && m == September && y == 2040) + || ((d == 9 || d == 10 || d == 11) && m == September && y == 2041) + || ((d == 29 || d == 30) && m == September && y == 2042) + || ((d == 16 || d == 17 || d == 18) && m == September && y == 2043) + || ((d == 4 || d == 5 || d == 6) && m == October && y == 2044) + || ((d == 25 || d == 26 || d == 27) && m == September && y == 2045) + || ((d >= 14 && d <= 17) && m == September && y == 2046) + || ((d == 3 || d == 4 || d == 5) && m == October && y == 2047) + || ((d == 21 || d == 22 || d == 23) && m == September && y == 2048) + || ((d >= 10 && d <= 13) && m == September && y == 2049) + || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2050) + || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2051) + || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2052) + // Hangul Proclamation of Korea || (d == 9 && m == October && y >= 2013) ) From 6a39e19dde1d0b498d90ccd39ff1673659752e60 Mon Sep 17 00:00:00 2001 From: "jonghee.lee" Date: Tue, 20 Jun 2023 17:20:11 +0900 Subject: [PATCH 2/8] apply substitute holiday to southkorea calendar --- ql/time/calendars/southkorea.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index b1c709e1346..a3016718fcd 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -112,7 +112,7 @@ namespace QuantLib { || ((d == 4 || d == 5 || d == 6) && m == February && y == 2019) || ((d >= 24 && d <= 27) && m == January && y == 2020) || ((d == 11 || d == 12 || d == 13) && m == February && y == 2021) - || (((d == 31 && m == January) || ((d == 1|| d == 2) + || (((d == 31 && m == January) || ((d == 1|| d == 2) && m == February)) && y == 2022) || ((d == 23 || d == 24) && m == January && y == 2023) || ((d >= 9 && d <= 12) && m == February && y == 2024) @@ -271,9 +271,12 @@ namespace QuantLib { || ((d == 3 || d == 4 || d == 5) && m == October && y == 2047) || ((d == 21 || d == 22 || d == 23) && m == September && y == 2048) || ((d >= 10 && d <= 13) && m == September && y == 2049) - || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2050) - || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2051) - || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2052) + || ((((d == 29|| d == 30) && m == September) + || (d == 1 && m == October)) && y == 2050) + || ((((d == 29|| d == 30) && m == September) + || (d == 1 && m == October)) && y == 2051) + || ((((d == 29|| d == 30) && m == September) + || (d == 1 && m == October)) && y == 2052) // Hangul Proclamation of Korea || (d == 9 && m == October && y >= 2013) From c26490f58f0549cc3e08e0d423a6cd12fcbfb464 Mon Sep 17 00:00:00 2001 From: "jonghee.lee" Date: Tue, 20 Jun 2023 17:22:12 +0900 Subject: [PATCH 3/8] add copyright --- ql/time/calendars/southkorea.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index a3016718fcd..e18e3a15bec 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -7,6 +7,7 @@ Copyright (C) 2015 Riccardo Barone Copyright (C) 2015 Paolo Mazzocchi Copyright (C) 2023 Skandinaviska Enskilda Banken AB (publ) + Copyright (C) 2023 Jonghee Lee This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ From b22d7c9e85dc5c730ccc87954c3010f3c2822aa9 Mon Sep 17 00:00:00 2001 From: jonghee Date: Tue, 20 Jun 2023 23:59:44 +0900 Subject: [PATCH 4/8] apply comments --- ql/time/calendars/southkorea.cpp | 15 ++++++++------- ql/time/calendars/southkorea.hpp | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index e18e3a15bec..49ad2c87932 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -61,12 +61,7 @@ namespace QuantLib { // Substitute holiday of National Foundation Day // Substitute holiday of Hangul Proclamation of Korea // Substitute holiday of Christmas Day - if ((w == Monday && (d == 2 || d == 3) && m == March && y > 2021) || - (w == Monday && (d == 6 || d == 7) && m == May && y > 2013) || - (w == Monday && (d == 16 || d == 17) && m == August && y > 2020) || - (w == Monday && (d == 4 || d == 5) && m == October && y > 2020) || - (w == Monday && (d == 10 || d == 11) && m == October && y > 2020) || - (w == Monday && (d == 26 || d == 27) && m == December && y > 2022)) { + if () { return false; } @@ -278,9 +273,15 @@ namespace QuantLib { || (d == 1 && m == October)) && y == 2051) || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2052) - // Hangul Proclamation of Korea || (d == 9 && m == October && y >= 2013) + // Substitute holiday + || (w == Monday && (d == 2 || d == 3) && m == March && y > 2021) + || (w == Monday && (d == 6 || d == 7) && m == May && y > 2013) + || (w == Monday && (d == 16 || d == 17) && m == August && y > 2020) + || (w == Monday && (d == 4 || d == 5) && m == October && y > 2020) + || (w == Monday && (d == 10 || d == 11) && m == October && y > 2020) + || (w == Monday && (d == 26 || d == 27) && m == December && y > 2022) ) return false; // NOLINT(readability-simplify-boolean-expr) diff --git a/ql/time/calendars/southkorea.hpp b/ql/time/calendars/southkorea.hpp index 85b7b1c741e..b95c853efed 100644 --- a/ql/time/calendars/southkorea.hpp +++ b/ql/time/calendars/southkorea.hpp @@ -50,7 +50,7 @@ namespace QuantLib { Other holidays for which no rule is given - (data available for 2004-2032 only:) + (data available for 2004-2043 only:)
  • Lunar New Year, the last day of the previous lunar year
  • Election Days
  • @@ -64,7 +64,8 @@ namespace QuantLib { Holidays for the Korea exchange (data from or - ): + + ):
    • Public holidays as listed above
    • Year-end closing
    • From cecfba0c659cdff40c0c6aedecd2e1fa9e361ff8 Mon Sep 17 00:00:00 2001 From: jonghee Date: Wed, 21 Jun 2023 00:05:58 +0900 Subject: [PATCH 5/8] remove some codes --- ql/time/calendars/southkorea.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index 49ad2c87932..7e021231a62 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -56,15 +56,6 @@ namespace QuantLib { Month m = date.month(); Year y = date.year(); - // Substitute holiday of Independence Day - // Substitute holiday of Children's Day - // Substitute holiday of National Foundation Day - // Substitute holiday of Hangul Proclamation of Korea - // Substitute holiday of Christmas Day - if () { - return false; - } - if (isWeekend(w) // New Year's Day || (d == 1 && m == January) From a801eb05dbd1fb9eff15f0ff952ba8c4c142fc33 Mon Sep 17 00:00:00 2001 From: jonghee Date: Wed, 21 Jun 2023 00:11:23 +0900 Subject: [PATCH 6/8] set year limit to 2053 --- ql/time/calendars/southkorea.cpp | 1 + ql/time/calendars/southkorea.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index 7e021231a62..848e528c1ef 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -264,6 +264,7 @@ namespace QuantLib { || (d == 1 && m == October)) && y == 2051) || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2052) + || ((d == 24 || d == 25) && m == January && y == 2053) // Hangul Proclamation of Korea || (d == 9 && m == October && y >= 2013) // Substitute holiday diff --git a/ql/time/calendars/southkorea.hpp b/ql/time/calendars/southkorea.hpp index b95c853efed..1e2c7d90cf5 100644 --- a/ql/time/calendars/southkorea.hpp +++ b/ql/time/calendars/southkorea.hpp @@ -50,7 +50,7 @@ namespace QuantLib {
    Other holidays for which no rule is given - (data available for 2004-2043 only:) + (data available for 2004-2053 only:)
    • Lunar New Year, the last day of the previous lunar year
    • Election Days
    • From fe5043bd128cc63b31b463383f5fd09df0ac2ba9 Mon Sep 17 00:00:00 2001 From: jonghee Date: Wed, 21 Jun 2023 00:12:52 +0900 Subject: [PATCH 7/8] make space --- ql/time/calendars/southkorea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index 848e528c1ef..7221782ffee 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -99,7 +99,7 @@ namespace QuantLib { || ((d == 4 || d == 5 || d == 6) && m == February && y == 2019) || ((d >= 24 && d <= 27) && m == January && y == 2020) || ((d == 11 || d == 12 || d == 13) && m == February && y == 2021) - || (((d == 31 && m == January) || ((d == 1|| d == 2) + || (((d == 31 && m == January) || ((d == 1 || d == 2) && m == February)) && y == 2022) || ((d == 23 || d == 24) && m == January && y == 2023) || ((d >= 9 && d <= 12) && m == February && y == 2024) From 7c1e0143d21b8af1af7f29beb6a5557c92582a32 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 20 Jun 2023 17:37:34 +0200 Subject: [PATCH 8/8] Associate substitute rules with original ones --- ql/time/calendars/southkorea.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ql/time/calendars/southkorea.cpp b/ql/time/calendars/southkorea.cpp index 7221782ffee..fbfbb655ee1 100644 --- a/ql/time/calendars/southkorea.cpp +++ b/ql/time/calendars/southkorea.cpp @@ -61,24 +61,27 @@ namespace QuantLib { || (d == 1 && m == January) // Independence Day || (d == 1 && m == March) + || (w == Monday && (d == 2 || d == 3) && m == March && y > 2021) // Arbour Day || (d == 5 && m == April && y <= 2005) // Labour Day || (d == 1 && m == May) // Children's Day || (d == 5 && m == May) - || (d == 7 && m == May && y == 2018) - || (d == 6 && m == May && y == 2019) + || (w == Monday && (d == 6 || d == 7) && m == May && y > 2013) // Memorial Day || (d == 6 && m == June) // Constitution Day || (d == 17 && m == July && y <= 2007) // Liberation Day || (d == 15 && m == August) + || (w == Monday && (d == 16 || d == 17) && m == August && y > 2020) // National Foundation Day || (d == 3 && m == October) + || (w == Monday && (d == 4 || d == 5) && m == October && y > 2020) // Christmas Day || (d == 25 && m == December) + || (w == Monday && (d == 26 || d == 27) && m == December && y > 2022) // Lunar New Year || ((d == 21 || d == 22 || d == 23) && m == January && y == 2004) @@ -265,15 +268,10 @@ namespace QuantLib { || ((((d == 29|| d == 30) && m == September) || (d == 1 && m == October)) && y == 2052) || ((d == 24 || d == 25) && m == January && y == 2053) + // Hangul Proclamation of Korea || (d == 9 && m == October && y >= 2013) - // Substitute holiday - || (w == Monday && (d == 2 || d == 3) && m == March && y > 2021) - || (w == Monday && (d == 6 || d == 7) && m == May && y > 2013) - || (w == Monday && (d == 16 || d == 17) && m == August && y > 2020) - || (w == Monday && (d == 4 || d == 5) && m == October && y > 2020) || (w == Monday && (d == 10 || d == 11) && m == October && y > 2020) - || (w == Monday && (d == 26 || d == 27) && m == December && y > 2022) ) return false; // NOLINT(readability-simplify-boolean-expr)