QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
romania.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2010 StatPro Italia srl
5 Copyright (C) 2015 Riccardo Barone
6 Copyright (C) 2018 Matthias Lungwitz
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22#include <ql/time/calendars/romania.hpp>
23#include <ql/errors.hpp>
24
25namespace QuantLib {
26
28 // all calendar instances share the same implementation instance
29 static ext::shared_ptr<Calendar::Impl> publicImpl =
30 ext::make_shared<Romania::PublicImpl>();
31 static ext::shared_ptr<Calendar::Impl> bvbImpl =
32 ext::make_shared<Romania::BVBImpl>();
33 switch (market) {
34 case Public:
35 impl_ = publicImpl;
36 break;
37 case BVB:
38 impl_ = bvbImpl;
39 break;
40 default:
41 QL_FAIL("unknown market");
42 }
43 }
44
45 bool Romania::PublicImpl::isBusinessDay(const Date& date) const {
46 Weekday w = date.weekday();
47 Day d = date.dayOfMonth(), dd = date.dayOfYear();
48 Month m = date.month();
49 Year y = date.year();
50 Day em = easterMonday(y);
51 if (isWeekend(w)
52 // New Year's Day
53 || (d == 1 && m == January)
54 // Day after New Year's Day
55 || (d == 2 && m == January)
56 // Unification Day
57 || (d == 24 && m == January)
58 // Orthodox Easter Monday
59 || (dd == em)
60 // Labour Day
61 || (d == 1 && m == May)
62 // Pentecost
63 || (dd == em+49)
64 // Children's Day (since 2017)
65 || (d == 1 && m == June && y >= 2017)
66 // St Marys Day
67 || (d == 15 && m == August)
68 // Feast of St Andrew
69 || (d == 30 && m == November)
70 // National Day
71 || (d == 1 && m == December)
72 // Christmas
73 || (d == 25 && m == December)
74 // 2nd Day of Chritsmas
75 || (d == 26 && m == December))
76 return false; // NOLINT(readability-simplify-boolean-expr)
77 return true;
78 }
79
80 bool Romania::BVBImpl::isBusinessDay(const Date& date) const {
82 return false;
83 Day d = date.dayOfMonth();
84 Month m = date.month();
85 Year y = date.year();
86 if (// one-off closing days
87 (d == 24 && m == December && y == 2014) ||
88 (d == 31 && m == December && y == 2014)
89 )
90 return false; // NOLINT(readability-simplify-boolean-expr)
91 return true;
92 }
93
94}
95
static Day easterMonday(Year)
expressed relative to first day of year
Definition: calendar.cpp:235
bool isWeekend(Weekday) const override
Definition: calendar.cpp:231
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
Day dayOfYear() const
One-based (Jan 1st = 1)
Definition: date.hpp:404
bool isBusinessDay(const Date &) const override
Definition: romania.cpp:80
bool isBusinessDay(const Date &) const override
Definition: romania.cpp:45
Romania(Market market=BVB)
Definition: romania.cpp:27
@ Public
Public holidays.
Definition: romania.hpp:72
@ BVB
Bucharest stock-exchange.
Definition: romania.hpp:73
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
@ June
Definition: date.hpp:62
Definition: any.hpp:35