Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cme.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <qle/calendars/cme.hpp>
20
21using namespace QuantLib;
22
23namespace QuantExt {
24
26
27 // All calendar instances share the same implementation instance
28 static ext::shared_ptr<QuantLib::Calendar::Impl> impl(new Impl);
29 impl_ = impl;
30}
31
32bool CME::Impl::isBusinessDay(const Date& date) const {
33
34 Weekday w = date.weekday();
35 Day d = date.dayOfMonth();
36 Month m = date.month();
37 Year y = date.year();
38
39 Day dd = date.dayOfYear();
40 Day em = easterMonday(y);
41
42 if (isWeekend(w)
43 // New Year's Day (possibly moved to Monday if on Sunday)
44 || ((d == 1 || (d == 2 && w == Monday)) && m == January)
45 // Martin Luther King's birthday (third Monday in January)
46 || (y >= 1998 && (d >= 15 && d <= 21) && w == Monday && m == January)
47 // Washington's birthday (third Monday in February)
48 || ((d >= 15 && d <= 21) && w == Monday && m == February)
49 // Good Friday
50 || (dd == em - 3)
51 // Memorial Day (last Monday in May)
52 || (d >= 25 && w == Monday && m == May)
53 // Independence Day (Monday if Sunday or Friday if Saturday)
54 || ((d == 4 || (d == 5 && w == Monday) || (d == 3 && w == Friday)) && m == July)
55 // Labor Day (first Monday in September)
56 || (d <= 7 && w == Monday && m == September)
57 // Thanksgiving Day (fourth Thursday in November)
58 || ((d >= 22 && d <= 28) && w == Thursday && m == November)
59 // Christmas (Monday if Sunday or Friday if Saturday)
60 || ((d == 25 || (d == 26 && w == Monday) || (d == 24 && w == Friday)) && m == December))
61 return false;
62
63 return true;
64}
65
66} // namespace QuantExt
bool isBusinessDay(const QuantLib::Date &d) const override
Definition: cme.cpp:32
CME Group exchange calendars.