/src/quantlib/ql/time/calendars/unitedstates.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl |
5 | | Copyright (C) 2003, 2004, 2005, 2006 StatPro Italia srl |
6 | | Copyright (C) 2004 Ferdinando Ametrano |
7 | | Copyright (C) 2017 Peter Caspers |
8 | | Copyright (C) 2017 Oleg Kulkov |
9 | | Copyright (C) 2023 Skandinaviska Enskilda Banken AB (publ) |
10 | | |
11 | | This file is part of QuantLib, a free-software/open-source library |
12 | | for financial quantitative analysts and developers - http://quantlib.org/ |
13 | | |
14 | | QuantLib is free software: you can redistribute it and/or modify it |
15 | | under the terms of the QuantLib license. You should have received a |
16 | | copy of the license along with this program; if not, please email |
17 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
18 | | <https://www.quantlib.org/license.shtml>. |
19 | | |
20 | | This program is distributed in the hope that it will be useful, but WITHOUT |
21 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
22 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
23 | | */ |
24 | | |
25 | | /*! \file unitedstates.hpp |
26 | | \brief US calendars |
27 | | */ |
28 | | |
29 | | #ifndef quantlib_united_states_calendar_hpp |
30 | | #define quantlib_united_states_calendar_hpp |
31 | | |
32 | | #include <ql/time/calendar.hpp> |
33 | | |
34 | | namespace QuantLib { |
35 | | |
36 | | //! United States calendars |
37 | | /*! Public holidays (see https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays): |
38 | | <ul> |
39 | | <li>Saturdays</li> |
40 | | <li>Sundays</li> |
41 | | <li>New Year's Day, January 1st (possibly moved to Monday if |
42 | | actually on Sunday, or to Friday if on Saturday)</li> |
43 | | <li>Martin Luther King's birthday, third Monday in January (since |
44 | | 1983)</li> |
45 | | <li>Presidents' Day (a.k.a. Washington's birthday), |
46 | | third Monday in February</li> |
47 | | <li>Memorial Day, last Monday in May</li> |
48 | | <li>Juneteenth, June 19th (moved to Monday if Sunday or |
49 | | Friday if Saturday)</li> |
50 | | <li>Independence Day, July 4th (moved to Monday if Sunday or |
51 | | Friday if Saturday)</li> |
52 | | <li>Labor Day, first Monday in September</li> |
53 | | <li>Columbus Day, second Monday in October</li> |
54 | | <li>Veterans' Day, November 11th (moved to Monday if Sunday or |
55 | | Friday if Saturday)</li> |
56 | | <li>Thanksgiving Day, fourth Thursday in November</li> |
57 | | <li>Christmas, December 25th (moved to Monday if Sunday or Friday |
58 | | if Saturday)</li> |
59 | | </ul> |
60 | | |
61 | | Note that since 2015 Independence Day only impacts Libor if it |
62 | | falls on a weekday (see <https://www.theice.com/iba/libor>, |
63 | | <https://www.theice.com/marketdata/reports/170> and |
64 | | <https://www.theice.com/publicdocs/LIBOR_Holiday_Calendar_2015.pdf> |
65 | | for the fixing and value date calendars). |
66 | | |
67 | | Holidays for the stock exchange (data from http://www.nyse.com): |
68 | | <ul> |
69 | | <li>Saturdays</li> |
70 | | <li>Sundays</li> |
71 | | <li>New Year's Day, January 1st (possibly moved to Monday if |
72 | | actually on Sunday)</li> |
73 | | <li>Martin Luther King's birthday, third Monday in January (since |
74 | | 1998)</li> |
75 | | <li>Presidents' Day (a.k.a. Washington's birthday), |
76 | | third Monday in February</li> |
77 | | <li>Good Friday</li> |
78 | | <li>Memorial Day, last Monday in May</li> |
79 | | <li>Independence Day, July 4th (moved to Monday if Sunday or |
80 | | Friday if Saturday)</li> |
81 | | <li>Labor Day, first Monday in September</li> |
82 | | <li>Thanksgiving Day, fourth Thursday in November</li> |
83 | | <li>Presidential election day, first Tuesday in November of election |
84 | | years (until 1980)</li> |
85 | | <li>Christmas, December 25th (moved to Monday if Sunday or Friday |
86 | | if Saturday)</li> |
87 | | <li>Special historic closings (see |
88 | | http://www.nyse.com/pdfs/closings.pdf)</li> |
89 | | </ul> |
90 | | |
91 | | Holidays for the government bond market (data from |
92 | | http://www.bondmarkets.com): |
93 | | <ul> |
94 | | <li>Saturdays</li> |
95 | | <li>Sundays</li> |
96 | | <li>New Year's Day, January 1st (possibly moved to Monday if |
97 | | actually on Sunday)</li> |
98 | | <li>Martin Luther King's birthday, third Monday in January (since |
99 | | 1983)</li> |
100 | | <li>Presidents' Day (a.k.a. Washington's birthday), |
101 | | third Monday in February</li> |
102 | | <li>Good Friday</li> |
103 | | <li>Memorial Day, last Monday in May</li> |
104 | | <li>Independence Day, July 4th (moved to Monday if Sunday or |
105 | | Friday if Saturday)</li> |
106 | | <li>Labor Day, first Monday in September</li> |
107 | | <li>Columbus Day, second Monday in October</li> |
108 | | <li>Veterans' Day, November 11th (moved to Monday if Sunday or |
109 | | Friday if Saturday)</li> |
110 | | <li>Thanksgiving Day, fourth Thursday in November</li> |
111 | | <li>Christmas, December 25th (moved to Monday if Sunday or Friday |
112 | | if Saturday)</li> |
113 | | </ul> |
114 | | |
115 | | Holidays for the North American Energy Reliability Council |
116 | | (data from http://www.nerc.com/~oc/offpeaks.html): |
117 | | <ul> |
118 | | <li>Saturdays</li> |
119 | | <li>Sundays</li> |
120 | | <li>New Year's Day, January 1st (possibly moved to Monday if |
121 | | actually on Sunday)</li> |
122 | | <li>Memorial Day, last Monday in May</li> |
123 | | <li>Independence Day, July 4th (moved to Monday if Sunday)</li> |
124 | | <li>Labor Day, first Monday in September</li> |
125 | | <li>Thanksgiving Day, fourth Thursday in November</li> |
126 | | <li>Christmas, December 25th (moved to Monday if Sunday)</li> |
127 | | </ul> |
128 | | |
129 | | Holidays for the Federal Reserve Bankwire System |
130 | | (data from https://www.federalreserve.gov/aboutthefed/k8.htm |
131 | | and https://www.frbservices.org/about/holiday-schedules): |
132 | | <ul> |
133 | | <li>Saturdays</li> |
134 | | <li>Sundays</li> |
135 | | <li>New Year's Day, January 1st (possibly moved to Monday if |
136 | | actually on Sunday)</li> |
137 | | <li>Martin Luther King's birthday, third Monday in January (since |
138 | | 1983)</li> |
139 | | <li>Presidents' Day (a.k.a. Washington's birthday), |
140 | | third Monday in February</li> |
141 | | <li>Memorial Day, last Monday in May</li> |
142 | | <li>Juneteenth, June 19th (moved to Monday if Sunday)</li> |
143 | | <li>Independence Day, July 4th (moved to Monday if Sunday)</li> |
144 | | <li>Labor Day, first Monday in September</li> |
145 | | <li>Columbus Day, second Monday in October</li> |
146 | | <li>Veterans' Day, November 11th (moved to Monday if Sunday)</li> |
147 | | <li>Thanksgiving Day, fourth Thursday in November</li> |
148 | | <li>Christmas, December 25th (moved to Monday if Sunday)</li> |
149 | | </ul> |
150 | | |
151 | | \ingroup calendars |
152 | | |
153 | | \test the correctness of the returned results is tested |
154 | | against a list of known holidays. |
155 | | */ |
156 | | class UnitedStates : public Calendar { |
157 | | private: |
158 | | class SettlementImpl : public Calendar::WesternImpl { |
159 | | public: |
160 | 0 | std::string name() const override { return "US settlement"; } |
161 | | bool isBusinessDay(const Date&) const override; |
162 | | }; |
163 | | class LiborImpactImpl final : public SettlementImpl { |
164 | | public: |
165 | 0 | std::string name() const override { return "US with Libor impact"; } |
166 | | bool isBusinessDay(const Date&) const override; |
167 | | }; |
168 | | class NyseImpl final : public Calendar::WesternImpl { |
169 | | public: |
170 | 692 | std::string name() const override { return "New York stock exchange"; } |
171 | | bool isBusinessDay(const Date&) const override; |
172 | | }; |
173 | | class GovernmentBondImpl : public Calendar::WesternImpl { |
174 | | public: |
175 | 379 | std::string name() const override { return "US government bond market"; } |
176 | | bool isBusinessDay(const Date&) const override; |
177 | | }; |
178 | | class SofrImpl final : public GovernmentBondImpl { |
179 | | public: |
180 | 0 | std::string name() const override { return "SOFR fixing calendar"; } |
181 | | bool isBusinessDay(const Date&) const override; |
182 | | }; |
183 | | class NercImpl final : public Calendar::WesternImpl { |
184 | | public: |
185 | 0 | std::string name() const override { |
186 | 0 | return "North American Energy Reliability Council"; |
187 | 0 | } |
188 | | bool isBusinessDay(const Date&) const override; |
189 | | }; |
190 | | class FederalReserveImpl final : public Calendar::WesternImpl { |
191 | | public: |
192 | 279 | std::string name() const override { return "Federal Reserve Bankwire System"; } |
193 | | bool isBusinessDay(const Date&) const override; |
194 | | }; |
195 | | public: |
196 | | //! US calendars |
197 | | enum Market { Settlement, //!< generic settlement calendar |
198 | | NYSE, //!< New York stock exchange calendar |
199 | | GovernmentBond, //!< government-bond calendar |
200 | | NERC, //!< off-peak days for NERC |
201 | | LiborImpact, //!< Libor impact calendar |
202 | | FederalReserve, //!< Federal Reserve Bankwire System |
203 | | SOFR //!< SOFR fixing calendar |
204 | | }; |
205 | | |
206 | | explicit UnitedStates(Market market); |
207 | | }; |
208 | | |
209 | | } |
210 | | |
211 | | |
212 | | #endif |