From 07cdc7e7de3f5ac6fc726b2b283bff2bd236a96a Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Wed, 10 Jul 2024 22:24:07 -0500 Subject: [PATCH] Sync with QuantLib 1.35 (rc) --- ChangeLog | 8 ++++++ DESCRIPTION | 4 +-- inst/NEWS.Rd | 7 +++++ src/ql/time/calendar.cpp | 4 +-- src/ql/time/calendars/chile.cpp | 36 +++++++++++++++++++++++++- src/ql/time/calendars/chile.hpp | 2 +- src/ql/time/calendars/india.cpp | 10 ++++--- src/ql/time/calendars/india.hpp | 4 +-- src/ql/time/calendars/unitedstates.cpp | 17 +++++++++--- 9 files changed, 77 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 103704d..d0b7ca0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-07-10 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + + * src/ql/time/calendars/chile.{cpp,hpp}: Updated from QuantLib 1.35 (rc) + * src/ql/time/calendars/india.{cpp,hpp}: Idem + * src/ql/time/calendars/unitedstates.cpp: Idem + 2024-05-19 Dirk Eddelbuettel * README.md: Use tinyverse.netlify.app for dependency badge diff --git a/DESCRIPTION b/DESCRIPTION index 4e30987..f03382e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: qlcal Type: Package Title: R Bindings to the Calendaring Functionality of 'QuantLib' -Version: 0.0.11 -Date: 2024-04-27 +Version: 0.0.11.1 +Date: 2024-07-10 Author: Dirk Eddelbuettel; the authors and contributors of QuantLib Maintainer: Dirk Eddelbuettel Description: 'QuantLib' bindings are provided for R using 'Rcpp' via an evolved version diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 775d1ab..252c877 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -3,6 +3,13 @@ \newcommand{\ghpr}{\href{https://github.com/qlcal/qlcal-r/pull/#1}{##1}} \newcommand{\ghit}{\href{https://github.com/qlcal/qlcal-r/issues/#1}{##1}} +\section{Changes in version 0.0.12 (2024-07-xx)}{ + \itemize{ + \item Synchronized with QuantLib 1.35 (rc) + \item Calendar updates for Chile, India, United States + } +} + \section{Changes in version 0.0.11 (2024-04-27)}{ \itemize{ \item Synchronized with QuantLib 1.34 diff --git a/src/ql/time/calendar.cpp b/src/ql/time/calendar.cpp index 3eb916d..801c228 100644 --- a/src/ql/time/calendar.cpp +++ b/src/ql/time/calendar.cpp @@ -197,7 +197,7 @@ namespace QuantLib { } Day Calendar::WesternImpl::easterMonday(Year y) { - static const Day EasterMonday[] = { + static const unsigned char EasterMonday[] = { 98, 90, 103, 95, 114, 106, 91, 111, 102, // 1901-1909 87, 107, 99, 83, 103, 95, 115, 99, 91, 111, // 1910-1919 96, 87, 107, 92, 112, 103, 95, 108, 100, 91, // 1920-1929 @@ -239,7 +239,7 @@ namespace QuantLib { } Day Calendar::OrthodoxImpl::easterMonday(Year y) { - static const Day EasterMonday[] = { + static const unsigned char EasterMonday[] = { 105, 118, 110, 102, 121, 106, 126, 118, 102, // 1901-1909 122, 114, 99, 118, 110, 95, 115, 106, 126, 111, // 1910-1919 103, 122, 107, 99, 119, 110, 123, 115, 107, 126, // 1920-1929 diff --git a/src/ql/time/calendars/chile.cpp b/src/ql/time/calendars/chile.cpp index 3343769..cb3caf2 100644 --- a/src/ql/time/calendars/chile.cpp +++ b/src/ql/time/calendars/chile.cpp @@ -21,6 +21,35 @@ namespace QuantLib { + namespace { + + // Celebrated on the Winter Solstice day, except in 2021, when it was the day after. + inline bool isAboriginalPeopleDay(Day d, Month m, Year y) { + static const unsigned char aboriginalPeopleDay[] = { + 21, 21, 21, 20, 20, 21, 21, 20, 20, // 2021-2029 + 21, 21, 20, 20, 21, 21, 20, 20, 21, 21, // 2030-2039 + 20, 20, 21, 21, 20, 20, 21, 21, 20, 20, // 2040-2049 + 20, 21, 20, 20, 20, 21, 20, 20, 20, 21, // 2050-2059 + 20, 20, 20, 21, 20, 20, 20, 21, 20, 20, // 2060-2069 + 20, 21, 20, 20, 20, 21, 20, 20, 20, 20, // 2070-2079 + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 2080-2089 + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 2090-2099 + 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, // 2100-2109 + 21, 21, 20, 21, 21, 21, 20, 21, 21, 21, // 2110-2119 + 20, 21, 21, 21, 20, 21, 21, 21, 20, 21, // 2120-2129 + 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, // 2130-2139 + 20, 20, 21, 21, 20, 20, 21, 21, 20, 20, // 2140-2149 + 21, 21, 20, 20, 21, 21, 20, 20, 21, 21, // 2150-2159 + 20, 20, 21, 21, 20, 20, 21, 21, 20, 20, // 2160-2169 + 20, 21, 20, 20, 20, 21, 20, 20, 20, 21, // 2170-2179 + 20, 20, 20, 21, 20, 20, 20, 21, 20, 20, // 2180-2189 + 20, 21, 20, 20, 20, 21, 20, 20, 20, 20 // 2190-2199 + }; + return m == June && y >= 2021 && d == aboriginalPeopleDay[y-2021]; + } + + } + Chile::Chile(Market) { // all calendar instances share the same implementation instance static ext::shared_ptr impl(new Chile::SseImpl); @@ -39,16 +68,20 @@ namespace QuantLib { // New Year's Day || (d == 1 && m == January) || (d == 2 && m == January && w == Monday && y > 2016) + // Papal visit in 2018 + || (d == 16 && m == January && y == 2018) // Good Friday || (dd == em-3) // Easter Saturday || (dd == em-2) + // Census Day in 2017 + || (d == 19 && m == April && y == 2017) // Labour Day || (d == 1 && m == May) // Navy Day || (d == 21 && m == May) // Day of Aboriginal People - || (d == 21 && m == June && y >= 2021) + || isAboriginalPeopleDay(d, m, y) // St. Peter and St. Paul || (d >= 26 && d <= 29 && m == June && w == Monday) || (d == 2 && m == July && w == Monday) @@ -57,6 +90,7 @@ namespace QuantLib { // Assumption Day || (d == 15 && m == August) // Independence Day + || (d == 16 && m == September && y == 2022) || (d == 17 && m == September && ((w == Monday && y >= 2007) || (w == Friday && y > 2016))) || (d == 18 && m == September) // Army Day diff --git a/src/ql/time/calendars/chile.hpp b/src/ql/time/calendars/chile.hpp index 46acfcf..c66f185 100644 --- a/src/ql/time/calendars/chile.hpp +++ b/src/ql/time/calendars/chile.hpp @@ -40,7 +40,7 @@ namespace QuantLib {
  • Easter Saturday
  • Labour Day, May 1st
  • Navy Day, May 21st
  • -
  • Day of Aboriginal People, June 21st (since 2021)
  • +
  • Day of Aboriginal People, around June 21st (observed on each Winter Solstice) (since 2021)
  • Saint Peter and Saint Paul, June 29th (moved to the nearest Monday if it falls on a weekday)
  • Our Lady of Mount Carmel, July 16th
  • Assumption Day, August 15th
  • diff --git a/src/ql/time/calendars/india.cpp b/src/ql/time/calendars/india.cpp index 9b71262..93d3bb7 100644 --- a/src/ql/time/calendars/india.cpp +++ b/src/ql/time/calendars/india.cpp @@ -442,15 +442,19 @@ namespace QuantLib { || (d == 9 && m == April) // Id-Ul-Fitr (Ramadan Eid) || (d == 11 && m == April) - // Ram Navamiz + // Ram Navami || (d == 17 && m == April) // Mahavir Jayanti || (d == 21 && m == April) + // General Parliamentary Elections + || (d == 20 && m == May) // Buddha Pournima || (d == 23 && m == May) - // Bakri Id (estimated Sunday 16th or Monday 17th) + // Bakri Eid || (d == 17 && m == June) - // Id-E-Milad (estimated Sunday 15th or Monday 16th) + // Moharram + || (d == 17 && m == July) + // Eid-E-Milad (estimated Sunday 15th or Monday 16th) || (d == 16 && m == September) // Diwali-Laxmi Pujan || (d == 1 && m == November) diff --git a/src/ql/time/calendars/india.hpp b/src/ql/time/calendars/india.hpp index 45c7eb0..3604f05 100644 --- a/src/ql/time/calendars/india.hpp +++ b/src/ql/time/calendars/india.hpp @@ -30,7 +30,7 @@ namespace QuantLib { //! Indian calendars - /*! Holidays for the National Stock Exchange + /*! Clearing holidays for the National Stock Exchange (data from ):
    • Saturdays
    • @@ -64,7 +64,7 @@ namespace QuantLib {
    • Guru Nanak Jayanti
    - Note: The holidays Ramzan Id, Bakri Id and Id-E-Milad rely on estimates for 2023-2025. + Note: The holidays Ramzan Id, Bakri Id and Id-E-Milad rely on estimates for 2024-2025. \ingroup calendars */ class India : public Calendar { diff --git a/src/ql/time/calendars/unitedstates.cpp b/src/ql/time/calendars/unitedstates.cpp index d528791..198ff9a 100644 --- a/src/ql/time/calendars/unitedstates.cpp +++ b/src/ql/time/calendars/unitedstates.cpp @@ -281,9 +281,18 @@ namespace QuantLib { && y >= 1983) // Washington's birthday (third Monday in February) || isWashingtonBirthday(d, m, y, w) - // Good Friday (2015, 2021, 2023 are half day due to NFP/SIFMA; - // see ) - || (dd == em-3 && y != 2015 && y != 2021 && y != 2023) + // Good Friday. Since 1996 it's an early close and not a full market + // close when it coincides with the NFP release date, which is the + // first Friday of the month(*). + // See + // + // (*) The full rule is "the third Friday after the conclusion of the + // week which includes the 12th of the month". This is usually the + // first Friday of the next month, but can be the second Friday if the + // month has fewer than 31 days. Since Good Friday is always between + // March 20th and April 23rd, it can only coincide with the April NFP, + // which is always on the first Friday, because March has 31 days. + || (dd == em-3 && (y < 1996 || d > 7)) // Memorial Day (last Monday in May) || isMemorialDay(d, m, y, w) // Juneteenth (Monday if Sunday or Friday if Saturday) @@ -308,7 +317,7 @@ namespace QuantLib { if (// President Bush's Funeral (y == 2018 && m == December && d == 5) // Hurricane Sandy - || (y == 2012 && m == October && (d == 30)) + || (y == 2012 && m == October && d == 30) // President Reagan's funeral || (y == 2004 && m == June && d == 11) ) return false;