diff --git a/ql/time/calendars/unitedstates.cpp b/ql/time/calendars/unitedstates.cpp index 89b3281f28c..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; } @@ -84,9 +85,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 +364,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/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): + + \ingroup calendars \test the correctness of the returned results is tested 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...");