/src/quantlib/ql/time/calendars/poland.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <http://quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | #include <ql/time/calendars/poland.hpp> |
21 | | #include <ql/errors.hpp> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | 0 | Poland::Poland(Poland::Market market) { |
26 | | // all calendar instances share the same implementation instance |
27 | 0 | static auto settlementImpl = ext::make_shared<Poland::SettlementImpl>(); |
28 | 0 | static auto wseImpl = ext::make_shared<Poland::WseImpl>(); |
29 | 0 | switch (market) { |
30 | 0 | case Settlement: |
31 | 0 | impl_ = settlementImpl; |
32 | 0 | break; |
33 | 0 | case WSE: |
34 | 0 | impl_ = wseImpl; |
35 | 0 | break; |
36 | 0 | default: |
37 | 0 | QL_FAIL("unknown market"); |
38 | 0 | } |
39 | 0 | } |
40 | | |
41 | 0 | bool Poland::SettlementImpl::isBusinessDay(const Date& date) const { |
42 | 0 | Weekday w = date.weekday(); |
43 | 0 | Day d = date.dayOfMonth(), dd = date.dayOfYear(); |
44 | 0 | Month m = date.month(); |
45 | 0 | Year y = date.year(); |
46 | 0 | Day em = easterMonday(y); |
47 | 0 | if (isWeekend(w) |
48 | | // Easter Monday |
49 | 0 | || (dd == em) |
50 | | // Corpus Christi |
51 | 0 | || (dd == em+59) |
52 | | // New Year's Day |
53 | 0 | || (d == 1 && m == January) |
54 | | // Epiphany |
55 | 0 | || (d == 6 && m == January && y >= 2011) |
56 | | // May Day |
57 | 0 | || (d == 1 && m == May) |
58 | | // Constitution Day |
59 | 0 | || (d == 3 && m == May) |
60 | | // Assumption of the Blessed Virgin Mary |
61 | 0 | || (d == 15 && m == August) |
62 | | // All Saints Day |
63 | 0 | || (d == 1 && m == November) |
64 | | // Independence Day |
65 | 0 | || (d ==11 && m == November) |
66 | | // Christmas |
67 | 0 | || (d == 25 && m == December) |
68 | | // 2nd Day of Christmas |
69 | 0 | || (d == 26 && m == December)) |
70 | 0 | return false; // NOLINT(readability-simplify-boolean-expr) |
71 | 0 | return true; |
72 | 0 | } |
73 | | |
74 | | |
75 | 0 | bool Poland::WseImpl::isBusinessDay(const Date& date) const { |
76 | | // Additional holidays for Warsaw Stock Exchange |
77 | | // see https://www.gpw.pl/session-details |
78 | 0 | Day d = date.dayOfMonth(); |
79 | 0 | Month m = date.month(); |
80 | |
|
81 | 0 | if ( |
82 | 0 | (d == 24 && m == December) |
83 | 0 | || (d == 31 && m == December) |
84 | 0 | ) return false; // NOLINT(readability-simplify-boolean-expr) |
85 | | |
86 | 0 | return SettlementImpl::isBusinessDay(date); |
87 | 0 | } |
88 | | |
89 | | } |
90 | | |