Skip to content

Commit

Permalink
Sync with QuantLib 1.35 (rc)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Jul 11, 2024
1 parent b15fcad commit 07cdc7e
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 15 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2024-07-10 Dirk Eddelbuettel <[email protected]>

* 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 <[email protected]>

* README.md: Use tinyverse.netlify.app for dependency badge
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Description: 'QuantLib' bindings are provided for R using 'Rcpp' via an evolved version
Expand Down
7 changes: 7 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ql/time/calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 35 additions & 1 deletion src/ql/time/calendars/chile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Calendar::Impl> impl(new Chile::SseImpl);
Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ql/time/calendars/chile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace QuantLib {
<li>Easter Saturday</li>
<li>Labour Day, May 1st</li>
<li>Navy Day, May 21st</li>
<li>Day of Aboriginal People, June 21st (since 2021)</li>
<li>Day of Aboriginal People, around June 21st (observed on each Winter Solstice) (since 2021)</li>
<li>Saint Peter and Saint Paul, June 29th (moved to the nearest Monday if it falls on a weekday)</li>
<li>Our Lady of Mount Carmel, July 16th</li>
<li>Assumption Day, August 15th</li>
Expand Down
10 changes: 7 additions & 3 deletions src/ql/time/calendars/india.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/ql/time/calendars/india.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace QuantLib {

//! Indian calendars
/*! Holidays for the National Stock Exchange
/*! Clearing holidays for the National Stock Exchange
(data from <http://www.nse-india.com/>):
<ul>
<li>Saturdays</li>
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace QuantLib {
<li>Guru Nanak Jayanti</li>
</ul>
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 {
Expand Down
17 changes: 13 additions & 4 deletions src/ql/time/calendars/unitedstates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.sifma.org/resources/general/holiday-schedule/>)
|| (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 <https://www.sifma.org/resources/general/holiday-schedule/>
//
// (*) 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)
Expand All @@ -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;
Expand Down

0 comments on commit 07cdc7e

Please sign in to comment.