QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
poland.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) 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
21#include <ql/errors.hpp>
22
23namespace QuantLib {
24
26 // all calendar instances share the same implementation instance
27 static auto settlementImpl = ext::make_shared<Poland::SettlementImpl>();
28 static auto wseImpl = ext::make_shared<Poland::WseImpl>();
29 switch (market) {
30 case Settlement:
31 impl_ = settlementImpl;
32 break;
33 case WSE:
34 impl_ = wseImpl;
35 break;
36 default:
37 QL_FAIL("unknown market");
38 }
39 }
40
42 Weekday w = date.weekday();
43 Day d = date.dayOfMonth(), dd = date.dayOfYear();
44 Month m = date.month();
45 Year y = date.year();
46 Day em = easterMonday(y);
47 if (isWeekend(w)
48 // Easter Monday
49 || (dd == em)
50 // Corpus Christi
51 || (dd == em+59)
52 // New Year's Day
53 || (d == 1 && m == January)
54 // Epiphany
55 || (d == 6 && m == January && y >= 2011)
56 // May Day
57 || (d == 1 && m == May)
58 // Constitution Day
59 || (d == 3 && m == May)
60 // Assumption of the Blessed Virgin Mary
61 || (d == 15 && m == August)
62 // All Saints Day
63 || (d == 1 && m == November)
64 // Independence Day
65 || (d ==11 && m == November)
66 // Christmas
67 || (d == 25 && m == December)
68 // 2nd Day of Christmas
69 || (d == 26 && m == December))
70 return false; // NOLINT(readability-simplify-boolean-expr)
71 return true;
72 }
73
74
75 bool Poland::WseImpl::isBusinessDay(const Date& date) const {
76 // Additional holidays for Warsaw Stock Exchange
77 // see https://www.gpw.pl/session-details
78 Day d = date.dayOfMonth();
79 Month m = date.month();
80
81 if (
82 (d == 24 && m == December)
83 || (d == 31 && m == December)
84 ) return false; // NOLINT(readability-simplify-boolean-expr)
85
87 }
88
89}
90
static Day easterMonday(Year)
expressed relative to first day of year
Definition: calendar.cpp:199
bool isWeekend(Weekday) const override
Definition: calendar.cpp:195
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:396
Weekday weekday() const
Definition: date.hpp:391
Day dayOfYear() const
One-based (Jan 1st = 1)
Definition: date.hpp:400
bool isBusinessDay(const Date &) const override
Definition: poland.cpp:41
bool isBusinessDay(const Date &) const override
Definition: poland.cpp:75
Market
PL calendars.
Definition: poland.hpp:65
@ WSE
Warsaw stock exchange calendar.
Definition: poland.hpp:66
@ Settlement
Settlement calendar.
Definition: poland.hpp:65
Poland(Market market=Settlement)
Definition: poland.cpp:25
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
@ December
Definition: date.hpp:68
@ August
Definition: date.hpp:64
@ January
Definition: date.hpp:57
@ May
Definition: date.hpp:61
@ November
Definition: date.hpp:67
Definition: any.hpp:37
Polish calendar.