Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
switzerland.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
20
21namespace QuantExt {
22using namespace QuantLib;
23
25 // all calendar instances share the same implementation instance
26 static ext::shared_ptr<Calendar::Impl> settlementImpl(new Switzerland::SettlementImpl);
27 static ext::shared_ptr<Calendar::Impl> sixImpl(new Switzerland::SixImpl);
28 switch (market) {
29 case Settlement:
30 impl_ = settlementImpl;
31 break;
32 case SIX:
33 impl_ = sixImpl;
34 break;
35 default:
36 QL_FAIL("unknown market");
37 }
38}
39
40bool Switzerland::SettlementImpl::isBusinessDay(const Date& date) const {
41 Weekday w = date.weekday();
42 Day d = date.dayOfMonth(), dd = date.dayOfYear();
43 Month m = date.month();
44 Year y = date.year();
45 Day em = easterMonday(y);
46 if (isWeekend(w)
47 // New Year's Day
48 || (d == 1 && m == January)
49 // Berchtoldstag
50 || (d == 2 && m == January)
51 // Good Friday
52 || (dd == em - 3)
53 // Easter Monday
54 || (dd == em)
55 // Ascension Day
56 || (dd == em + 38)
57 // Whit Monday
58 || (dd == em + 49)
59 // Labour Day
60 || (d == 1 && m == May)
61 // National Day
62 || (d == 1 && m == August)
63 // Christmas
64 || (d == 25 && m == December)
65 // St. Stephen's Day
66 || (d == 26 && m == December))
67 return false;
68 return true;
69}
70
71bool Switzerland::SixImpl::isBusinessDay(const Date& date) const {
72 Weekday w = date.weekday();
73 Day d = date.dayOfMonth(), dd = date.dayOfYear();
74 Month m = date.month();
75 Year y = date.year();
76 Day em = easterMonday(y);
77 if (isWeekend(w)
78 // New Year's Day
79 || (d == 1 && m == January)
80 // Berchtoldstag
81 || (d == 2 && m == January)
82 // Good Friday
83 || (dd == em - 3)
84 // Easter Monday
85 || (dd == em)
86 // Ascension Day
87 || (dd == em + 38)
88 // Whit Monday
89 || (dd == em + 49)
90 // Labour Day
91 || (d == 1 && m == May)
92 // National Day
93 || (d == 1 && m == August)
94 // Christmas Eve
95 || (d == 24 && m == December)
96 // Christmas
97 || (d == 25 && m == December)
98 // St. Stephen's Day
99 || (d == 26 && m == December)
100 // New Year Eve
101 || (d == 31 && m == December))
102 return false;
103 return true;
104}
105
106} // namespace QuantExt
bool isBusinessDay(const Date &) const override
Definition: switzerland.cpp:40
bool isBusinessDay(const Date &) const override
Definition: switzerland.cpp:71
Switzerland(Market market=Settlement)
Definition: switzerland.cpp:24
@ Settlement
generic settlement calendar
Definition: switzerland.hpp:65
@ SIX
SIX Swiss Exchange calendar.
Definition: switzerland.hpp:66
Swiss calendar.