From fa81ccfbf95bdf9fcef108b21cd8491d8ce2cb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Gerdin=20B=C3=B6rjesson?= Date: Tue, 12 Dec 2023 15:52:03 +0100 Subject: [PATCH 1/2] Stop moving Juneteenth to Friday if Saturday for Fed --- ql/time/calendars/unitedstates.cpp | 8 ++++---- test-suite/calendars.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ql/time/calendars/unitedstates.cpp b/ql/time/calendars/unitedstates.cpp index 89b3281f28c..be4149d0f10 100644 --- a/ql/time/calendars/unitedstates.cpp +++ b/ql/time/calendars/unitedstates.cpp @@ -84,9 +84,9 @@ namespace QuantLib { } } - bool isJuneteenth(Day d, Month m, Year y, Weekday w) { + bool isJuneteenth(Day d, Month m, Year y, Weekday w, bool moveToFriday = true) { // declared in 2021, but only observed by exchanges since 2022 - return (d == 19 || (d == 20 && w == Monday) || (d == 18 && w == Friday)) + return (d == 19 || (d == 20 && w == Monday) || ((d == 18 && w == Friday) && moveToFriday)) && m == June && y >= 2022; } } @@ -363,8 +363,8 @@ namespace QuantLib { || isWashingtonBirthday(d, m, y, w) // Memorial Day (last Monday in May) || isMemorialDay(d, m, y, w) - // Juneteenth (Monday if Sunday or Friday if Saturday) - || isJuneteenth(d, m, y, w) + // Juneteenth (Monday if Sunday) + || isJuneteenth(d, m, y, w, false) // Independence Day (Monday if Sunday) || ((d == 4 || (d == 5 && w == Monday)) && m == July) // Labor Day (first Monday in September) diff --git a/test-suite/calendars.cpp b/test-suite/calendars.cpp index 1bcf51daf85..90af9edec65 100644 --- a/test-suite/calendars.cpp +++ b/test-suite/calendars.cpp @@ -387,6 +387,36 @@ BOOST_AUTO_TEST_CASE(testSOFR) { BOOST_ERROR(testDate << " should not be a fixing date for " << sofr.name()); } +BOOST_AUTO_TEST_CASE(testUSFederalReserveJuneteenth) { + BOOST_TEST_MESSAGE("Testing holiday occurrence of Juneteenth for US Federal Reserve calendar..."); + + auto fedCalendar = UnitedStates(UnitedStates::FederalReserve); + + std::vector expectedHol; + // Sunday, moved to Monday 20th: expectedHol.emplace_back(19, June, 2022); + expectedHol.emplace_back(20, June, 2022); + expectedHol.emplace_back(19, June, 2023); + expectedHol.emplace_back(19, June, 2024); + expectedHol.emplace_back(19, June, 2025); + // Saturday: expectedHol.emplace_back(19, June, 2026); + expectedHol.emplace_back(19, June, 2027); + expectedHol.emplace_back(19, June, 2028); + expectedHol.emplace_back(19, June, 2029); + expectedHol.emplace_back(19, June, 2030); + expectedHol.emplace_back(19, June, 2031); + // Saturday: expectedHol.emplace_back(19, June, 2032); + // Sunday, moved to Monday 20th: expectedHol.emplace_back(19, June, 2033); + expectedHol.emplace_back(20, June, 2033); + for (Date holiday : expectedHol) { + if (!fedCalendar.isHoliday(holiday)) + BOOST_ERROR(holiday << " should be a holiday for " << fedCalendar.name()); + } + + Date notMovedToFriday(18, June, 2027); + if (fedCalendar.isHoliday(notMovedToFriday)) + BOOST_ERROR(notMovedToFriday << " should not be a holiday for " << fedCalendar.name()); +} + BOOST_AUTO_TEST_CASE(testTARGET) { BOOST_TEST_MESSAGE("Testing TARGET holiday list..."); From 91607179b9c09a2163fc2c21fe4d77a4fbc3e28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Gerdin=20B=C3=B6rjesson?= Date: Mon, 18 Dec 2023 17:11:38 +0100 Subject: [PATCH 2/2] Add docstring with references for US-FED calendar --- ql/time/calendars/unitedstates.cpp | 3 ++- ql/time/calendars/unitedstates.hpp | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ql/time/calendars/unitedstates.cpp b/ql/time/calendars/unitedstates.cpp index be4149d0f10..88fa4200e12 100644 --- a/ql/time/calendars/unitedstates.cpp +++ b/ql/time/calendars/unitedstates.cpp @@ -6,6 +6,7 @@ Copyright (C) 2003, 2004, 2005, 2006 StatPro Italia srl Copyright (C) 2017 Peter Caspers Copyright (C) 2017 Oleg Kulkov + 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/ @@ -35,7 +36,7 @@ namespace QuantLib { // third Monday in February return (d >= 15 && d <= 21) && w == Monday && m == February; } else { - // February 22nd, possily adjusted + // February 22nd, possibly adjusted return (d == 22 || (d == 23 && w == Monday) || (d == 21 && w == Friday)) && m == February; } diff --git a/ql/time/calendars/unitedstates.hpp b/ql/time/calendars/unitedstates.hpp index 5218cd3fa1e..faebb3baf2c 100644 --- a/ql/time/calendars/unitedstates.hpp +++ b/ql/time/calendars/unitedstates.hpp @@ -6,6 +6,7 @@ Copyright (C) 2004 Ferdinando Ametrano Copyright (C) 2017 Peter Caspers Copyright (C) 2017 Oleg Kulkov + 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/ @@ -125,6 +126,28 @@ namespace QuantLib {
  • Christmas, December 25th (moved to Monday if Sunday)
  • + Holidays for the Federal Reserve Bankwire System + (data from https://www.federalreserve.gov/aboutthefed/k8.htm + and https://www.frbservices.org/about/holiday-schedules): +
      +
    • Saturdays
    • +
    • Sundays
    • +
    • New Year's Day, January 1st (possibly moved to Monday if + actually on Sunday)
    • +
    • Martin Luther King's birthday, third Monday in January (since + 1983)
    • +
    • Presidents' Day (a.k.a. Washington's birthday), + third Monday in February
    • +
    • Memorial Day, last Monday in May
    • +
    • Juneteenth, June 19th (moved to Monday if Sunday)
    • +
    • Independence Day, July 4th (moved to Monday if Sunday)
    • +
    • Labor Day, first Monday in September
    • +
    • Columbus Day, second Monday in October
    • +
    • Veterans' Day, November 11th (moved to Monday if Sunday)
    • +
    • Thanksgiving Day, fourth Thursday in November
    • +
    • Christmas, December 25th (moved to Monday if Sunday)
    • +
    + \ingroup calendars \test the correctness of the returned results is tested