QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
time
calendars
turkey.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) 2005 Sercan Atalik
5
Copyright (C) 2010 StatPro Italia srl
6
Copyright (C) 2018 Matthias Lungwitz
7
Copyright (C) 2022 Skandinaviska Enskilda Banken AB (publ)
8
9
This file is part of QuantLib, a free-software/open-source library
10
for financial quantitative analysts and developers - http://quantlib.org/
11
12
QuantLib is free software: you can redistribute it and/or modify it
13
under the terms of the QuantLib license. You should have received a
14
copy of the license along with this program; if not, please email
15
<quantlib-dev@lists.sf.net>. The license is also available online at
16
<http://quantlib.org/license.shtml>.
17
18
This program is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
FOR A PARTICULAR PURPOSE. See the license for more details.
21
*/
22
23
#include <
ql/time/calendars/turkey.hpp
>
24
25
namespace
QuantLib
{
26
27
Turkey::Turkey
() {
28
// all calendar instances share the same implementation instance
29
static
ext::shared_ptr<Calendar::Impl> impl(
new
Turkey::Impl
);
30
impl_
= impl;
31
}
32
33
bool
Turkey::Impl::isWeekend
(
Weekday
w)
const
{
34
return
w ==
Saturday
|| w ==
Sunday
;
35
}
36
37
bool
Turkey::Impl::isBusinessDay
(
const
Date
& date)
const
{
38
Weekday
w = date.
weekday
();
39
Day
d
= date.
dayOfMonth
();
40
Month
m = date.
month
();
41
Year
y
= date.
year
();
42
43
if
(
isWeekend
(w)
44
// New Year's Day
45
|| (
d
== 1 && m ==
January
)
46
// 23 nisan / National Holiday
47
|| (
d
== 23 && m ==
April
)
48
// 1 may/ National Holiday
49
|| (
d
== 1 && m ==
May
)
50
// 19 may/ National Holiday
51
|| (
d
== 19 && m ==
May
)
52
// 15 july / National Holiday (since 2017)
53
|| (
d
== 15 && m ==
July
&&
y
>= 2017)
54
// 30 aug/ National Holiday
55
|| (
d
== 30 && m ==
August
)
56
///29 ekim National Holiday
57
|| (
d
== 29 && m ==
October
))
58
return
false
;
59
60
// Local Holidays
61
if
(
y
== 2004) {
62
// Kurban
63
if
((m ==
February
&&
d
<= 4)
64
// Ramadan
65
|| (m ==
November
&&
d
>= 14 &&
d
<= 16))
66
return
false
;
67
}
else
if
(
y
== 2005) {
68
// Kurban
69
if
((m ==
January
&&
d
>= 19 &&
d
<= 21)
70
// Ramadan
71
|| (m ==
November
&&
d
>= 2 &&
d
<= 5))
72
return
false
;
73
}
else
if
(
y
== 2006) {
74
// Kurban
75
if
((m ==
January
&&
d
>= 10 &&
d
<= 13)
76
// Ramadan
77
|| (m ==
October
&&
d
>= 23 &&
d
<= 25)
78
// Kurban
79
|| (m ==
December
&&
d
== 31))
80
return
false
;
81
}
else
if
(
y
== 2007) {
82
// Kurban
83
if
((m ==
January
&&
d
<= 3)
84
// Ramadan
85
|| (m ==
October
&&
d
>= 12 &&
d
<= 14)
86
// Kurban
87
|| (m ==
December
&&
d
>= 20 &&
d
<= 23))
88
return
false
;
89
}
else
if
(
y
== 2008) {
90
// Ramadan
91
if
((m ==
September
&&
d
== 30)
92
|| (m ==
October
&&
d
<= 2)
93
// Kurban
94
|| (m ==
December
&&
d
>= 8 &&
d
<= 11))
95
return
false
;
96
}
else
if
(
y
== 2009) {
97
// Ramadan
98
if
((m ==
September
&&
d
>= 20 &&
d
<= 22)
99
// Kurban
100
|| (m ==
November
&&
d
>= 27 &&
d
<= 30))
101
return
false
;
102
}
else
if
(
y
== 2010) {
103
// Ramadan
104
if
((m ==
September
&&
d
>= 9 &&
d
<= 11)
105
// Kurban
106
|| (m ==
November
&&
d
>= 16 &&
d
<= 19))
107
return
false
;
108
}
else
if
(
y
== 2011) {
109
// not clear from borsainstanbul.com
110
if
((m ==
October
&&
d
== 1)
111
|| (m ==
November
&&
d
>= 9 &&
d
<= 13))
112
return
false
;
113
}
else
if
(
y
== 2012) {
114
// Ramadan
115
if
((m ==
August
&&
d
>= 18 &&
d
<= 21)
116
// Kurban
117
|| (m ==
October
&&
d
>= 24 &&
d
<= 28))
118
return
false
;
119
}
else
if
(
y
== 2013) {
120
// Ramadan
121
if
((m ==
August
&&
d
>= 7 &&
d
<= 10)
122
// Kurban
123
|| (m ==
October
&&
d
>= 14 &&
d
<= 18)
124
// additional holiday for Republic Day
125
|| (m ==
October
&&
d
== 28))
126
return
false
;
127
}
else
if
(
y
== 2014) {
128
// Ramadan
129
if
((m ==
July
&&
d
>= 27 &&
d
<= 30)
130
// Kurban
131
|| (m ==
October
&&
d
>= 4 &&
d
<= 7)
132
// additional holiday for Republic Day
133
|| (m ==
October
&&
d
== 29))
134
return
false
;
135
}
else
if
(
y
== 2015) {
136
// Ramadan
137
if
((m ==
July
&&
d
>= 17 &&
d
<= 19)
138
// Kurban
139
|| (m ==
October
&&
d
>= 24 &&
d
<= 27))
140
return
false
;
141
}
else
if
(
y
== 2016) {
142
// Ramadan
143
if
((m ==
July
&&
d
>= 5 &&
d
<= 7)
144
// Kurban
145
|| (m ==
September
&&
d
>= 12 &&
d
<= 15))
146
return
false
;
147
}
else
if
(
y
== 2017) {
148
// Ramadan
149
if
((m ==
June
&&
d
>= 25 &&
d
<= 27)
150
// Kurban
151
|| (m ==
September
&&
d
>= 1 &&
d
<= 4))
152
return
false
;
153
}
else
if
(
y
== 2018) {
154
// Ramadan
155
if
((m ==
June
&&
d
>= 15 &&
d
<= 17)
156
// Kurban
157
|| (m ==
August
&&
d
>= 21 &&
d
<= 24))
158
return
false
;
159
}
else
if
(
y
== 2019) {
160
// Ramadan
161
if
((m ==
June
&&
d
>= 4 &&
d
<= 6)
162
// Kurban
163
|| (m ==
August
&&
d
>= 11 &&
d
<= 14))
164
return
false
;
165
}
else
if
(
y
== 2020) {
166
// Ramadan
167
if
((m ==
May
&&
d
>= 24 &&
d
<= 26)
168
// Kurban
169
|| (m ==
July
&&
d
== 31) || (m ==
August
&&
d
>= 1 &&
d
<= 3))
170
return
false
;
171
}
else
if
(
y
== 2021) {
172
// Ramadan
173
if
((m ==
May
&&
d
>= 13 &&
d
<= 15)
174
// Kurban
175
|| (m ==
July
&&
d
>= 20 &&
d
<= 23))
176
return
false
;
177
}
else
if
(
y
== 2022) {
178
// Ramadan
179
if
((m ==
May
&&
d
>= 2 &&
d
<= 4)
180
// Kurban
181
|| (m ==
July
&&
d
>= 9 &&
d
<= 12))
182
return
false
;
183
}
else
if
(
y
== 2023) {
184
// Ramadan
185
if
((m ==
April
&&
d
>= 21 &&
d
<= 23)
186
// Kurban
187
// July 1 is also a holiday but falls on a Saturday which is already flagged
188
|| (m ==
June
&&
d
>= 28 &&
d
<= 30))
189
return
false
;
190
}
else
if
(
y
== 2024) {
191
// Note: Holidays >= 2024 are not yet officially anounced by borsaistanbul.com
192
// and need further validation
193
// Ramadan
194
if
((m ==
April
&&
d
>= 10 &&
d
<= 12)
195
// Kurban
196
|| (m ==
June
&&
d
>= 17 &&
d
<= 19))
197
return
false
;
198
}
else
if
(
y
== 2025) {
199
// Ramadan
200
if
((m ==
March
&&
d
== 31) || (m ==
April
&&
d
>= 1 &&
d
<= 2)
201
// Kurban
202
|| (m ==
June
&&
d
>= 6 &&
d
<= 9))
203
return
false
;
204
}
else
if
(
y
== 2026) {
205
// Ramadan
206
if
((m ==
March
&&
d
>= 20 &&
d
<= 22)
207
// Kurban
208
|| (m ==
May
&&
d
>= 26 &&
d
<= 29))
209
return
false
;
210
}
else
if
(
y
== 2027) {
211
// Ramadan
212
if
((m ==
March
&&
d
>= 10 &&
d
<= 12)
213
// Kurban
214
|| (m ==
May
&&
d
>= 16 &&
d
<= 19))
215
return
false
;
216
}
else
if
(
y
== 2028) {
217
// Ramadan
218
if
((m ==
February
&&
d
>= 27 &&
d
<= 29)
219
// Kurban
220
|| (m ==
May
&&
d
>= 4 &&
d
<= 7))
221
return
false
;
222
}
else
if
(
y
== 2029) {
223
// Ramadan
224
if
((m ==
February
&&
d
>= 15 &&
d
<= 17)
225
// Kurban
226
|| (m ==
April
&&
d
>= 23 &&
d
<= 26))
227
return
false
;
228
}
else
if
(
y
== 2030) {
229
// Ramadan
230
if
((m ==
February
&&
d
>= 5 &&
d
<= 7)
231
// Kurban
232
|| (m ==
April
&&
d
>= 13 &&
d
<= 16))
233
return
false
;
234
}
else
if
(
y
== 2031) {
235
// Ramadan
236
if
((m ==
January
&&
d
>= 25 &&
d
<= 27)
237
// Kurban
238
|| (m ==
April
&&
d
>= 2 &&
d
<= 5))
239
return
false
;
240
}
else
if
(
y
== 2032) {
241
// Ramadan
242
if
((m ==
January
&&
d
>= 14 &&
d
<= 16)
243
// Kurban
244
|| (m ==
March
&&
d
>= 21 &&
d
<= 24))
245
return
false
;
246
}
else
if
(
y
== 2033) {
247
// Ramadan
248
if
((m ==
January
&&
d
>= 3 &&
d
<= 5) || (m ==
December
&&
d
== 23)
249
// Kurban
250
|| (m ==
March
&&
d
>= 11 &&
d
<= 14))
251
return
false
;
252
}
else
if
(
y
== 2034) {
253
// Ramadan
254
if
((m ==
December
&&
d
>= 12 &&
d
<= 14)
255
// Kurban
256
|| (m ==
February
&&
d
== 28) || (m ==
March
&&
d
>= 1 &&
d
<= 3))
257
return
false
;
258
}
259
return
true
;
260
}
261
262
}
263
y
Real y
Definition:
andreasenhugevolatilityinterpl.cpp:46
QuantLib::Calendar::isWeekend
bool isWeekend(Weekday w) const
Definition:
calendar.hpp:255
QuantLib::Calendar::impl_
ext::shared_ptr< Impl > impl_
Definition:
calendar.hpp:72
QuantLib::Date
Concrete date class.
Definition:
date.hpp:125
QuantLib::Date::month
Month month() const
Definition:
date.cpp:82
QuantLib::Date::year
Year year() const
Definition:
date.cpp:93
QuantLib::Date::dayOfMonth
Day dayOfMonth() const
Definition:
date.hpp:400
QuantLib::Date::weekday
Weekday weekday() const
Definition:
date.hpp:395
QuantLib::Turkey::Impl
Definition:
turkey.hpp:56
QuantLib::Turkey::Impl::isBusinessDay
bool isBusinessDay(const Date &) const override
Definition:
turkey.cpp:37
QuantLib::Turkey::Impl::isWeekend
bool isWeekend(Weekday) const override
Definition:
turkey.cpp:33
QuantLib::Turkey::Turkey
Turkey()
Definition:
turkey.cpp:27
d
Date d
Definition:
exchangeratemanager.cpp:32
QuantLib::Year
Integer Year
Year number.
Definition:
date.hpp:87
QuantLib::Day
Integer Day
Day number.
Definition:
date.hpp:53
QuantLib::Month
Month
Month names.
Definition:
date.hpp:57
QuantLib::Weekday
Weekday
Definition:
weekday.hpp:41
QuantLib::December
@ December
Definition:
date.hpp:68
QuantLib::August
@ August
Definition:
date.hpp:64
QuantLib::January
@ January
Definition:
date.hpp:57
QuantLib::July
@ July
Definition:
date.hpp:63
QuantLib::May
@ May
Definition:
date.hpp:61
QuantLib::March
@ March
Definition:
date.hpp:59
QuantLib::February
@ February
Definition:
date.hpp:58
QuantLib::April
@ April
Definition:
date.hpp:60
QuantLib::November
@ November
Definition:
date.hpp:67
QuantLib::October
@ October
Definition:
date.hpp:66
QuantLib::June
@ June
Definition:
date.hpp:62
QuantLib::September
@ September
Definition:
date.hpp:65
QuantLib::Sunday
@ Sunday
Definition:
weekday.hpp:41
QuantLib::Saturday
@ Saturday
Definition:
weekday.hpp:47
QuantLib
Definition:
any.hpp:35
turkey.hpp
Turkish calendar.
Generated by
Doxygen
1.9.5