QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
israel.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2015 Paolo Mazzocchi
5 Copyright (C) 2015 Riccardo Barone
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
22#include <ql/errors.hpp>
23
24namespace QuantLib {
25
27 // all calendar instances share the same implementation instance
28 static ext::shared_ptr<Calendar::Impl> SettlementImpl(
30 static ext::shared_ptr<Calendar::Impl> TelAvivImpl(
32 switch (market) {
33 case Settlement:
34 impl_ = SettlementImpl;
35 break;
36 case TASE:
38 break;
39 default:
40 QL_FAIL("unknown market");
41 }
42 }
43
45 return w == Friday || w == Saturday;
46 }
47
48 bool Israel::TelAvivImpl::isBusinessDay(const Date& date) const {
49 Weekday w = date.weekday();
50 Day d = date.dayOfMonth();
51 Month m = date.month();
52 Year y = date.year();
53
54 if (isWeekend(w)
55 //Purim
56 || (d == 24 && m == February && y == 2013)
57 || (d == 16 && m == March && y == 2014)
58 || (d == 05 && m == March && y == 2015)
59 || (d == 24 && m == March && y == 2016)
60 || (d == 12 && m == March && y == 2017)
61 || (d == 1 && m == March && y == 2018)
62 || (d == 21 && m == March && y == 2019)
63 || (d == 10 && m == March && y == 2020)
64 || (d == 26 && m == February && y == 2021)
65 || (d == 17 && m == March && y == 2022)
66 || (d == 7 && m == March && y == 2023)
67 || (d == 24 && m == March && y == 2024)
68 || (d == 14 && m == March && y == 2025)
69 || (d == 3 && m == March && y == 2026)
70 || (d == 23 && m == March && y == 2027)
71 || (d == 12 && m == March && y == 2028)
72 || (d == 1 && m == March && y == 2029)
73 || (d == 19 && m == March && y == 2030)
74 || (d == 9 && m == March && y == 2031)
75 || (d == 26 && m == February && y == 2032)
76 || (d == 15 && m == March && y == 2033)
77 || (d == 5 && m == March && y == 2034)
78 || (d == 25 && m == March && y == 2035)
79 || (d == 13 && m == March && y == 2036)
80 || (d == 1 && m == March && y == 2037)
81 || (d == 21 && m == March && y == 2038)
82 || (d == 10 && m == March && y == 2039)
83 || (d == 28 && m == February && y == 2040)
84 || (d == 17 && m == March && y == 2041)
85 || (d == 6 && m == March && y == 2042)
86 || (d == 26 && m == March && y == 2043)
87 || (d == 13 && m == March && y == 2044)
88 //Passover I and Passover VII
89 || ((((d==25||d==26||d==31)&&m==March)||(d==1&&m==April))&&y==2013)
90 || ((d==14||d==15||d==20||d==21) && m == April && y == 2014)
91 || ((d==3 ||d==4 ||d==9 ||d==10) && m == April && y == 2015)
92 || ((d==22||d==23||d==28||d==29) && m == April && y == 2016)
93 || ((d==10||d==11||d==16||d==17) && m == April && y == 2017)
94 || (( (d==31&&m==March) ||((d==5||d==6)&&m==April))&&y== 2018)
95 || ((d == 20||d == 25 ||d == 26) && m == April && y == 2019)
96 || ((d==8 ||d==9 ||d==14||d==15) && m == April && y == 2020)
97 || (((d==28&&m==March)||(d==3&&m==April))&&y== 2021)
98 || ((d == 16 || d == 22) && m == April && y == 2022)
99 || ((d == 6 || d == 12) && m == April && y == 2023)
100 || ((d == 23 || d == 29) && m == April && y == 2024)
101 || ((d == 13 || d == 19) && m == April && y == 2025)
102 || ((d == 2 || d == 8 ) && m == April && y == 2026)
103 || ((d == 22 || d == 28) && m == April && y == 2027)
104 || ((d == 11 || d == 17) && m == April && y == 2028)
105 || (((d==31&&m==March)||(d==6&&m==April))&&y== 2029)
106 || ((d == 18 || d == 24) && m == April && y == 2030)
107 || ((d == 8 || d == 14) && m == April && y == 2031)
108 || (((d==27&&m==March)||(d==2&&m==April))&&y== 2032)
109 || ((d == 14 || d == 20) && m == April && y == 2033)
110 || ((d == 4 || d == 10) && m == April && y == 2034)
111 || ((d == 24 || d == 30) && m == April && y == 2035)
112 || ((d == 12 || d == 18) && m == April && y == 2036)
113 || (((d==31&&m==March)||(d==6&&m==April))&&y== 2037)
114 || ((d == 20 || d == 26) && m == April && y == 2038)
115 || ((d == 9 || d == 15) && m == April && y == 2039)
116 || (((d==29&&m==March)||(d==4&&m==April))&&y== 2040)
117 || ((d == 16 || d == 22) && m == April && y == 2041)
118 || ((d == 5 || d == 11) && m == April && y == 2042)
119 || (((d==25&&m==April)||(d==1&&m==May))&& y == 2043)
120 || ((d == 12 || d == 18) && m == April && y == 2044)
121 //Memorial and Indipendence Day
122 || ((d == 15 || d == 16) && m == April && y == 2013)
123 || ((d == 5 || d == 6 ) && m == May && y == 2014)
124 || ((d == 22 || d == 23) && m == April && y == 2015)
125 || ((d == 11 || d == 12) && m == May && y == 2016)
126 || ((d == 1 || d == 2 ) && m == May && y == 2017)
127 || ((d == 18 || d == 19) && m == April && y == 2018)
128 || ((d == 8 || d == 9 ) && m == May && y == 2019)
129 || ((d == 28 || d == 29) && m == April && y == 2020)
130 || ((d == 14 || d == 15) && m == April && y == 2021)
131 || ((d == 4 || d == 5 ) && m == May && y == 2022)
132 || ((d == 25 || d == 26) && m == April && y == 2023)
133 || ((d == 13 || d == 14) && m == May && y == 2024)
134 || (((d==30&&m==April)||(d==1&&m==May))&& y == 2025)
135 || ((d == 21 || d == 22) && m == April && y == 2026)
136 || ((d == 11 || d == 12) && m == May && y == 2027)
137 || ((d == 1 || d == 2 ) && m == May && y == 2028)
138 || ((d == 18 || d == 19) && m == April && y == 2029)
139 || ((d == 7 || d == 8 ) && m == May && y == 2030)
140 || ((d == 28 || d == 29) && m == April && y == 2031)
141 || ((d == 14 || d == 15) && m == April && y == 2032)
142 || ((d == 3 || d == 4 ) && m == May && y == 2033)
143 || ((d == 24 || d == 25) && m == April && y == 2034)
144 || ((d == 14 || d == 15) && m == May && y == 2035)
145 || (((d==30&&m==April)||(d==1&&m==May))&& y == 2036)
146 || ((d == 20 || d == 21) && m == April && y == 2037)
147 || ((d == 9 || d == 10) && m == May && y == 2038)
148 || ((d == 27 || d == 28) && m == April && y == 2039)
149 || ((d == 17 || d == 18) && m == April && y == 2040)
150 || ((d == 6 || d == 7 ) && m == May && y == 2041)
151 || ((d == 23 || d == 24) && m == April && y == 2042)
152 || ((d == 13 || d == 14) && m == May && y == 2043)
153 || ((d == 2 || d == 3 ) && m == May && y == 2044)
154 //Pentecost (Shavuot)
155 || ((d == 14 || d == 15) && m == May && y == 2013)
156 || ((d == 3 || d == 4 ) && m == June && y == 2014)
157 || ((d == 23 || d == 24) && m == May && y == 2015)
158 || ((d == 11 || d == 12) && m == June && y == 2016)
159 || ((d == 30 || d == 31) && m == May && y == 2017)
160 || ((d == 19 || d == 20) && m == May && y == 2018)
161 || ((d == 8 || d == 9 ) && m == June && y == 2019)
162 || ((d == 28 || d == 29) && m == May && y == 2020)
163 || (d == 17 && m == May && y == 2021)
164 || (d == 5 && m == June && y == 2022)
165 || (d == 26 && m == May && y == 2023)
166 || (d == 12 && m == June && y == 2024)
167 || (d == 2 && m == June && y == 2025)
168 || (d == 22 && m == May && y == 2026)
169 || (d == 11 && m == June && y == 2027)
170 || (d == 31 && m == May && y == 2028)
171 || (d == 20 && m == May && y == 2029)
172 || (d == 7 && m == June && y == 2030)
173 || (d == 28 && m == May && y == 2031)
174 || (d == 16 && m == May && y == 2032)
175 || (d == 3 && m == June && y == 2033)
176 || (d == 24 && m == May && y == 2034)
177 || (d == 13 && m == June && y == 2035)
178 || (d == 1 && m == June && y == 2036)
179 || (d == 20 && m == May && y == 2037)
180 || (d == 9 && m == June && y == 2038)
181 || (d == 29 && m == May && y == 2039)
182 || (d == 18 && m == May && y == 2040)
183 || (d == 5 && m == June && y == 2041)
184 || (d == 25 && m == May && y == 2042)
185 || (d == 14 && m == June && y == 2043)
186 || (d == 1 && m == June && y == 2044)
187 //Fast Day
188 || (d == 16 && m == July && y == 2013)
189 || (d == 5 && m == August && y == 2014)
190 || (d == 26 && m == July && y == 2015)
191 || (d == 14 && m == August && y == 2016)
192 || (d == 1 && m == August && y == 2017)
193 || (d == 22 && m == July && y == 2018)
194 || (d == 11 && m == August && y == 2019)
195 || (d == 30 && m == July && y == 2020)
196 || (d == 18 && m == July && y == 2021)
197 || (d == 7 && m == August && y == 2022)
198 || (d == 27 && m == July && y == 2023)
199 || (d == 13 && m == August && y == 2024)
200 || (d == 3 && m == August && y == 2025)
201 || (d == 23 && m == July && y == 2026)
202 || (d == 12 && m == August && y == 2027)
203 || (d == 1 && m == August && y == 2028)
204 || (d == 22 && m == July && y == 2029)
205 || (d == 8 && m == August && y == 2030)
206 || (d == 29 && m == July && y == 2031)
207 || (d == 18 && m == July && y == 2032)
208 || (d == 4 && m == August && y == 2033)
209 || (d == 25 && m == July && y == 2034)
210 || (d == 14 && m == August && y == 2035)
211 || (d == 3 && m == August && y == 2036)
212 || (d == 21 && m == July && y == 2037)
213 || (d == 10 && m == August && y == 2038)
214 || (d == 31 && m == July && y == 2039)
215 || (d == 19 && m == July && y == 2040)
216 || (d == 6 && m == August && y == 2041)
217 || (d == 27 && m == July && y == 2042)
218 || (d == 16 && m == August && y == 2043)
219 || (d == 2 && m == August && y == 2044)
220 //Jewish New Year
221 || ((d == 4 ||d == 5 || d == 6 ) && m == September && y == 2013)
222 || ((d == 24 ||d == 25|| d == 26) && m == September && y == 2014)
223 || ((d == 13 ||d == 14|| d == 15) && m == September && y == 2015)
224 || ((d == 2 ||d == 3 || d == 4 ) && m == October && y == 2016)
225 || ((d == 20 ||d == 21|| d == 22) && m == September && y == 2017)
226 || ((d == 9 ||d == 10|| d == 11) && m == September && y == 2018)
227 || ((((d==29||d==30)&&m==September)||(d==1&&m==October))&&y==2019)
228 || ((d == 19 || d == 20) && m == September && y == 2020)
229 || ((d == 7 || d == 8 ) && m == September && y == 2021)
230 || ((d == 26 || d == 27) && m == September && y == 2022)
231 || ((d == 16 || d == 17) && m == September && y == 2023)
232 || ((d == 3 || d == 4 ) && m == October && y == 2024)
233 || ((d == 23 || d == 24) && m == September && y == 2025)
234 || ((d == 12 || d == 13) && m == September && y == 2026)
235 || ((d == 2 || d == 3 ) && m == October && y == 2027)
236 || ((d == 21 || d == 22) && m == September && y == 2028)
237 || ((d == 10 || d == 11) && m == September && y == 2029)
238 || ((d == 28 || d == 29) && m == September && y == 2030)
239 || ((d == 18 || d == 19) && m == September && y == 2031)
240 || ((d == 6 || d == 7 ) && m == September && y == 2032)
241 || ((d == 24 || d == 25) && m == September && y == 2033)
242 || ((d == 14 || d == 15) && m == September && y == 2034)
243 || ((d == 4 || d == 5 ) && m == October && y == 2035)
244 || ((d == 22 || d == 23) && m == September && y == 2036)
245 || ((d == 10 || d == 11) && m == September && y == 2037)
246 || (((d==30&&m==September)||(d==01&&m==October))&&y==2038)
247 || ((d == 19 || d == 20) && m == September && y == 2039)
248 || ((d == 8 || d == 9 ) && m == September && y == 2040)
249 || ((d == 26 || d == 27) && m == September && y == 2041)
250 || ((d == 15 || d == 16) && m == September && y == 2042)
251 || ((d == 5 || d == 6 ) && m == October && y == 2043)
252 || ((d == 22 || d == 23) && m == September && y == 2044)
253 //Yom Kippur
254 || ((d == 13 || d == 14) && m == September && y == 2013)
255 || ((d == 3 || d == 4 ) && m == October && y == 2014)
256 || ((d == 22 || d == 23) && m == September && y == 2015)
257 || ((d == 11 || d == 12) && m == October && y == 2016)
258 || ((d == 29 || d == 30) && m == September && y == 2017)
259 || ((d == 18 || d == 19) && m == September && y == 2018)
260 || ((d == 8 || d == 9 ) && m == October && y == 2019)
261 || ((d == 27 || d == 28) && m == September && y == 2020)
262 || ((d == 15 || d == 16) && m == September && y == 2021)
263 || ((d == 4 || d == 5 ) && m == October && y == 2022)
264 || ((d == 24 || d == 25) && m == September && y == 2023)
265 || ((d == 11 || d == 12) && m == October && y == 2024)
266 || ((d == 1 || d == 2 ) && m == October && y == 2025)
267 || ((d == 20 || d == 21) && m == September && y == 2026)
268 || ((d == 10 || d == 11) && m == October && y == 2027)
269 || ((d == 29 || d == 30) && m == September && y == 2028)
270 || ((d == 18 || d == 19) && m == September && y == 2029)
271 || ((d == 6 || d == 7 ) && m == October && y == 2030)
272 || ((d == 26 || d == 27) && m == September && y == 2031)
273 || ((d == 14 || d == 15) && m == September && y == 2032)
274 || ((d == 2 || d == 3 ) && m == October && y == 2033)
275 || ((d == 22 || d == 23) && m == September && y == 2034)
276 || ((d == 12 || d == 13) && m == October && y == 2035)
277 || (((d==30&&m==September)||(d==01&&m==October))&&y==2036)
278 || ((d == 18 || d == 19) && m == September && y == 2037)
279 || ((d == 8 || d == 9 ) && m == October && y == 2038)
280 || ((d == 27 || d == 28) && m == September && y == 2039)
281 || ((d == 16 || d == 17) && m == September && y == 2040)
282 || ((d == 4 || d == 5 ) && m == October && y == 2041)
283 || ((d == 23 || d == 24) && m == September && y == 2042)
284 || ((d == 13 || d == 14) && m == October && y == 2043)
285 || (((d==30&&m==September)||(d==01&&m==October))&&y==2044)
286 //Sukkoth
287 || ((d == 18 || d == 19) && m == September && y == 2013)
288 || ((d == 8 || d == 9 ) && m == October && y == 2014)
289 || ((d == 27 || d == 28) && m == September && y == 2015)
290 || ((d == 16 || d == 17) && m == October && y == 2016)
291 || ((d == 4 || d == 5 ) && m == October && y == 2017)
292 || ((d == 23 || d == 24) && m == September && y == 2018)
293 || ((d == 13 || d == 14) && m == October && y == 2019)
294 || ((d == 2 || d == 3 ) && m == October && y == 2020)
295 || ((d == 20 || d == 21) && m == September && y == 2021)
296 || ((d == 9 || d == 10) && m == October && y == 2022)
297 || ((d == 29 || d == 30) && m == September && y == 2023)
298 || ((d == 16 || d == 17) && m == October && y == 2024)
299 || ((d == 6 || d == 7 ) && m == October && y == 2025)
300 || ((d == 25 || d == 26) && m == September && y == 2026)
301 || ((d == 15 || d == 16) && m == October && y == 2027)
302 || ((d == 4 || d == 5 ) && m == October && y == 2028)
303 || ((d == 23 || d == 24) && m == September && y == 2029)
304 || ((d == 11 || d == 12) && m == October && y == 2030)
305 || ((d == 1 || d == 2 ) && m == October && y == 2031)
306 || ((d == 19 || d == 20) && m == September && y == 2032)
307 || ((d == 7 || d == 8 ) && m == October && y == 2033)
308 || ((d == 27 || d == 28) && m == September && y == 2034)
309 || ((d == 17 || d == 18) && m == October && y == 2035)
310 || ((d == 5 || d == 6 ) && m == October && y == 2036)
311 || ((d == 23 || d == 24) && m == September && y == 2037)
312 || ((d == 13 || d == 14) && m == October && y == 2038)
313 || ((d == 2 || d == 3 ) && m == October && y == 2039)
314 || ((d == 21 || d == 22) && m == September && y == 2040)
315 || ((d == 9 || d == 10) && m == October && y == 2041)
316 || ((d == 28 || d == 29) && m == September && y == 2042)
317 || ((d == 18 || d == 19) && m == October && y == 2043)
318 || ((d == 5 || d == 6 ) && m == October && y == 2044)
319 //Simchat Tora
320 || ((d == 25 || d == 26) && m == September && y == 2013)
321 || ((d == 15 || d == 16) && m == October && y == 2014)
322 || ((d == 4 || d == 5 ) && m == October && y == 2015)
323 || ((d == 23 || d == 24) && m == October && y == 2016)
324 || ((d == 11 || d == 12) && m == October && y == 2017)
325 || (((d==30&&m==September)||(d==1&&m==October))&&y== 2018)
326 || ((d == 20 || d == 21) && m == October && y == 2019)
327 || ((d == 9 || d == 10) && m == October && y == 2020)
328 || ((d == 27 || d == 28) && m == September && y == 2021)
329 || ((d == 16 || d == 17) && m == October && y == 2022)
330 || ((d == 6 || d == 7 ) && m == October && y == 2023)
331 || ((d == 23 || d == 24) && m == October && y == 2024)
332 || ((d == 13 || d == 14) && m == October && y == 2025)
333 || ((d == 2 || d == 3 ) && m == October && y == 2026)
334 || ((d == 22 || d == 23) && m == October && y == 2027)
335 || ((d == 11 || d == 12) && m == October && y == 2028)
336 || (((d==30&&m==September)||(d==1&&m==October))&&y== 2029)
337 || ((d == 18 || d == 19) && m == October && y == 2030)
338 || ((d == 8 || d == 9 ) && m == October && y == 2031)
339 || ((d == 26 || d == 27) && m == September && y == 2032)
340 || ((d == 14 || d == 15) && m == October && y == 2033)
341 || ((d == 4 || d == 5 ) && m == October && y == 2034)
342 || ((d == 24 || d == 25) && m == October && y == 2035)
343 || ((d == 12 || d == 13) && m == October && y == 2036)
344 || (((d==30&&m==September)||(d==1&&m==October))&&y== 2037)
345 || ((d == 20 || d == 21) && m == October && y == 2038)
346 || ((d == 9 || d == 10) && m == October && y == 2039)
347 || ((d == 28 || d == 29) && m == September && y == 2040)
348 || ((d == 16 || d == 17) && m == October && y == 2041)
349 || ((d == 5 || d == 6 ) && m == October && y == 2042)
350 || ((d == 25 || d == 26) && m == October && y == 2043)
351 || ((d == 12 || d == 13) && m == October && y == 2044))
352 return false; // NOLINT(readability-simplify-boolean-expr)
353
354 return true;
355 }
356
357}
bool isWeekend(Weekday w) const
Definition: calendar.hpp:255
ext::shared_ptr< Impl > impl_
Definition: calendar.hpp:72
Concrete date class.
Definition: date.hpp:125
Month month() const
Definition: date.cpp:82
Year year() const
Definition: date.cpp:93
Day dayOfMonth() const
Definition: date.hpp:400
Weekday weekday() const
Definition: date.hpp:395
bool isBusinessDay(const Date &) const override
Definition: israel.cpp:48
bool isWeekend(Weekday) const override
Definition: israel.cpp:44
Israel(Market market=Settlement)
Definition: israel.cpp:26
@ TASE
Tel-Aviv stock exchange calendar.
Definition: israel.hpp:71
@ Settlement
generic settlement calendar
Definition: israel.hpp:70
Classes and functions for error handling.
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
Date d
Integer Year
Year number.
Definition: date.hpp:87
Integer Day
Day number.
Definition: date.hpp:53
Month
Month names.
Definition: date.hpp:57
@ August
Definition: date.hpp:64
@ July
Definition: date.hpp:63
@ May
Definition: date.hpp:61
@ March
Definition: date.hpp:59
@ February
Definition: date.hpp:58
@ April
Definition: date.hpp:60
@ October
Definition: date.hpp:66
@ June
Definition: date.hpp:62
@ September
Definition: date.hpp:65
@ Saturday
Definition: weekday.hpp:47
@ Friday
Definition: weekday.hpp:46
Israelian calendar.
Definition: any.hpp:35