QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
time
calendars
taiwan.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) 2004 FIMAT Group
5
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 StatPro Italia srl
6
Copyright (C) 2023 Skandinaviska Enskilda Banken AB (publ)
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/taiwan.hpp
>
23
24
namespace
QuantLib
{
25
26
Taiwan::Taiwan
(
Market
) {
27
// all calendar instances share the same implementation instance
28
static
ext::shared_ptr<Calendar::Impl> impl(
new
Taiwan::TsecImpl
);
29
impl_
= impl;
30
}
31
32
bool
Taiwan::TsecImpl::isWeekend
(
Weekday
w)
const
{
33
return
w ==
Saturday
|| w ==
Sunday
;
34
}
35
36
bool
Taiwan::TsecImpl::isBusinessDay
(
const
Date
& date)
const
{
37
Weekday
w = date.
weekday
();
38
Day
d
= date.
dayOfMonth
();
39
Month
m = date.
month
();
40
Year
y
= date.
year
();
41
42
if
(
isWeekend
(w)
43
// New Year's Day
44
|| (
d
== 1 && m ==
January
)
45
// Peace Memorial Day
46
|| (
d
== 28 && m ==
February
)
47
// Labor Day
48
|| (
d
== 1 && m ==
May
)
49
// Double Tenth
50
|| (
d
== 10 && m ==
October
)
51
)
52
return
false
;
53
54
if
(
y
== 2002) {
55
// Dragon Boat Festival and Moon Festival fall on Saturday
56
if
(
// Chinese Lunar New Year
57
(
d
>= 9 &&
d
<= 17 && m ==
February
)
58
// Tomb Sweeping Day
59
|| (
d
== 5 && m ==
April
)
60
)
61
return
false
;
62
}
63
64
if
(
y
== 2003) {
65
// Tomb Sweeping Day falls on Saturday
66
if
(
// Chinese Lunar New Year
67
((
d
>= 31 && m ==
January
) || (
d
<= 5 && m ==
February
))
68
// Dragon Boat Festival
69
|| (
d
== 4 && m ==
June
)
70
// Moon Festival
71
|| (
d
== 11 && m ==
September
)
72
)
73
return
false
;
74
}
75
76
if
(
y
== 2004) {
77
// Tomb Sweeping Day falls on Sunday
78
if
(
// Chinese Lunar New Year
79
(
d
>= 21 &&
d
<= 26 && m ==
January
)
80
// Dragon Boat Festival
81
|| (
d
== 22 && m ==
June
)
82
// Moon Festival
83
|| (
d
== 28 && m ==
September
)
84
)
85
return
false
;
86
}
87
88
if
(
y
== 2005) {
89
// Dragon Boat and Moon Festival fall on Saturday or Sunday
90
if
(
// Chinese Lunar New Year
91
(
d
>= 6 &&
d
<= 13 && m ==
February
)
92
// Tomb Sweeping Day
93
|| (
d
== 5 && m ==
April
)
94
// make up for Labor Day, not seen in other years
95
|| (
d
== 2 && m ==
May
)
96
)
97
return
false
;
98
}
99
100
if
(
y
== 2006) {
101
// Dragon Boat and Moon Festival fall on Saturday or Sunday
102
if
(
// Chinese Lunar New Year
103
((
d
>= 28 && m ==
January
) || (
d
<= 5 && m ==
February
))
104
// Tomb Sweeping Day
105
|| (
d
== 5 && m ==
April
)
106
// Dragon Boat Festival
107
|| (
d
== 31 && m ==
May
)
108
// Moon Festival
109
|| (
d
== 6 && m ==
October
)
110
)
111
return
false
;
112
}
113
114
if
(
y
== 2007) {
115
if
(
// Chinese Lunar New Year
116
(
d
>= 17 &&
d
<= 25 && m ==
February
)
117
// Tomb Sweeping Day
118
|| (
d
== 5 && m ==
April
)
119
// adjusted holidays
120
|| (
d
== 6 && m ==
April
)
121
|| (
d
== 18 && m ==
June
)
122
// Dragon Boat Festival
123
|| (
d
== 19 && m ==
June
)
124
// adjusted holiday
125
|| (
d
== 24 && m ==
September
)
126
// Moon Festival
127
|| (
d
== 25 && m ==
September
)
128
)
129
return
false
;
130
}
131
132
if
(
y
== 2008) {
133
if
(
// Chinese Lunar New Year
134
(
d
>= 4 &&
d
<= 11 && m ==
February
)
135
// Tomb Sweeping Day
136
|| (
d
== 4 && m ==
April
)
137
)
138
return
false
;
139
}
140
141
if
(
y
== 2009) {
142
if
(
// Public holiday
143
(
d
== 2 && m ==
January
)
144
// Chinese Lunar New Year
145
|| (
d
>= 24 && m ==
January
)
146
// Tomb Sweeping Day
147
|| (
d
== 4 && m ==
April
)
148
// Dragon Boat Festival
149
|| ((
d
== 28 ||
d
== 29) && m ==
May
)
150
// Moon Festival
151
|| (
d
== 3 && m ==
October
)
152
)
153
return
false
;
154
}
155
156
if
(
y
== 2010) {
157
if
(
// Chinese Lunar New Year
158
(
d
>= 13 &&
d
<= 21 && m ==
January
)
159
// Tomb Sweeping Day
160
|| (
d
== 5 && m ==
April
)
161
// Dragon Boat Festival
162
|| (
d
== 16 && m ==
May
)
163
// Moon Festival
164
|| (
d
== 22 && m ==
September
)
165
)
166
return
false
;
167
}
168
169
if
(
y
== 2011) {
170
if
(
// Spring Festival
171
(
d
>= 2 &&
d
<= 7 && m ==
February
)
172
// Children's Day
173
|| (
d
== 4 && m ==
April
)
174
// Tomb Sweeping Day
175
|| (
d
== 5 && m ==
April
)
176
// Labour Day
177
|| (
d
== 2 && m ==
May
)
178
// Dragon Boat Festival
179
|| (
d
== 6 && m ==
June
)
180
// Mid-Autumn Festival
181
|| (
d
== 12 && m ==
September
)
182
)
183
return
false
;
184
}
185
186
if
(
y
== 2012) {
187
if
(
// Spring Festival
188
(
d
>= 23 &&
d
<= 27 && m ==
January
)
189
// Peace Memorial Day
190
|| (
d
== 27 && m ==
February
)
191
// Children's Day
192
// Tomb Sweeping Day
193
|| (
d
== 4 && m ==
April
)
194
// Labour Day
195
|| (
d
== 1 && m ==
May
)
196
// Dragon Boat Festival
197
|| (
d
== 23 && m ==
June
)
198
// Mid-Autumn Festival
199
|| (
d
== 30 && m ==
September
)
200
// Memorial Day:
201
// Founding of the Republic of China
202
|| (
d
== 31 && m ==
December
)
203
)
204
return
false
;
205
}
206
207
if
(
y
== 2013) {
208
if
(
// Spring Festival
209
(
d
>= 10 &&
d
<= 15 && m ==
February
)
210
// Children's Day
211
|| (
d
== 4 && m ==
April
)
212
// Tomb Sweeping Day
213
|| (
d
== 5 && m ==
April
)
214
// Labour Day
215
|| (
d
== 1 && m ==
May
)
216
// Dragon Boat Festival
217
|| (
d
== 12 && m ==
June
)
218
// Mid-Autumn Festival
219
|| (
d
>= 19 &&
d
<= 20 && m ==
September
)
220
)
221
return
false
;
222
}
223
224
if
(
y
== 2014) {
225
if
(
// Lunar New Year
226
(
d
>= 28 &&
d
<= 30 && m ==
January
)
227
// Spring Festival
228
|| ((
d
== 31 && m ==
January
) || (
d
<= 4 && m ==
February
))
229
// Children's Day
230
|| (
d
== 4 && m ==
April
)
231
// Tomb Sweeping Day
232
|| (
d
== 5 && m ==
April
)
233
// Dragon Boat Festival
234
|| (
d
== 2 && m ==
June
)
235
// Mid-Autumn Festival
236
|| (
d
== 8 && m ==
September
)
237
)
238
return
false
;
239
}
240
241
if
(
y
== 2015) {
242
if
(
// adjusted holidays
243
(
d
== 2 && m ==
January
)
244
// Lunar New Year
245
|| (
d
>= 18 &&
d
<= 23 && m ==
February
)
246
// adjusted holidays
247
|| (
d
== 27 && m ==
February
)
248
// adjusted holidays
249
|| (
d
== 3 && m ==
April
)
250
// adjusted holidays
251
|| (
d
== 6 && m ==
April
)
252
// adjusted holidays
253
|| (
d
== 19 && m ==
June
)
254
// adjusted holidays
255
|| (
d
== 28 && m ==
September
)
256
// adjusted holidays
257
|| (
d
== 9 && m ==
October
)
258
)
259
return
false
;
260
}
261
262
if
(
y
== 2016) {
263
if
(
// Lunar New Year
264
(
d
>= 8 &&
d
<= 12 && m ==
February
)
265
// adjusted holidays
266
|| (
d
== 29 && m ==
February
)
267
// Children's Day
268
|| (
d
== 4 && m ==
April
)
269
// adjusted holidays
270
|| (
d
== 5 && m ==
April
)
271
// adjusted holidays
272
|| (
d
== 2 && m ==
May
)
273
// Dragon Boat Festival
274
|| (
d
== 9 && m ==
June
)
275
// adjusted holidays
276
|| (
d
== 10 && m ==
June
)
277
// Mid-Autumn Festival
278
|| (
d
== 15 && m ==
September
)
279
// adjusted holidays
280
|| (
d
== 16 && m ==
September
)
281
)
282
return
false
;
283
}
284
285
if
(
y
== 2017) {
286
if
(
// adjusted holidays
287
(
d
== 2 && m ==
January
)
288
// Lunar New Year
289
|| ((
d
>= 27 && m ==
January
) || (
d
== 1 && m ==
February
))
290
// adjusted holidays
291
|| (
d
== 27 && m ==
February
)
292
// adjusted holidays
293
|| (
d
== 3 && m ==
April
)
294
// Children's Day
295
|| (
d
== 4 && m ==
April
)
296
// adjusted holidays
297
|| (
d
== 29 && m ==
May
)
298
// Dragon Boat Festival
299
|| (
d
== 30 && m ==
May
)
300
// Mid-Autumn Festival
301
|| (
d
== 4 && m ==
October
)
302
// adjusted holidays
303
|| (
d
== 9 && m ==
October
)
304
)
305
return
false
;
306
}
307
308
if
(
y
== 2018) {
309
if
(
// Lunar New Year
310
(
d
>= 15 &&
d
<= 20 && m ==
February
)
311
// Children's Day
312
|| (
d
== 4 && m ==
April
)
313
// Tomb Sweeping Day
314
|| (
d
== 5 && m ==
April
)
315
// adjusted holidays
316
|| (
d
== 6 && m ==
April
)
317
// Dragon Boat Festival
318
|| (
d
== 18 && m ==
June
)
319
// Mid-Autumn Festival
320
|| (
d
== 24 && m ==
September
)
321
// adjusted holidays
322
|| (
d
== 31 && m ==
December
)
323
)
324
return
false
;
325
}
326
327
if
(
y
== 2019) {
328
if
(
// Lunar New Year
329
(
d
>= 4 &&
d
<= 8 && m ==
February
)
330
// adjusted holidays
331
|| (
d
== 1 && m ==
March
)
332
// Children's Day
333
|| (
d
== 4 && m ==
April
)
334
// Tomb Sweeping Day
335
|| (
d
== 5 && m ==
April
)
336
// Dragon Boat Festival
337
|| (
d
== 7 && m ==
June
)
338
// Mid-Autumn Festival
339
|| (
d
== 13 && m ==
September
)
340
// adjusted holidays
341
|| (
d
== 11 && m ==
October
)
342
)
343
return
false
;
344
}
345
346
if
(
y
== 2020) {
347
if
(
// adjusted holiday
348
(
d
== 23 && m ==
January
)
349
// Lunar New Year
350
|| (
d
>= 24 &&
d
<= 29 && m ==
January
)
351
// adjusted holiday
352
|| (
d
== 2 && m ==
April
)
353
// adjusted holiday
354
|| (
d
== 3 && m ==
April
)
355
// Dragon Boat Festival
356
|| (
d
== 25 && m ==
June
)
357
// adjusted holiday
358
|| (
d
== 26 && m ==
June
)
359
// Mid-Autumn Festival
360
|| (
d
== 1 && m ==
October
)
361
// adjusted holiday
362
|| (
d
== 2 && m ==
October
)
363
// adjusted holiday
364
|| (
d
== 9 && m ==
October
)
365
)
366
return
false
;
367
}
368
369
if
(
y
== 2021) {
370
// Tomb Sweeping Day falls on Sunday
371
if
(
// adjusted holiday
372
(
d
== 10 && m ==
February
)
373
// Lunar New Year
374
|| (
d
>= 11 &&
d
<= 16 && m ==
February
)
375
// adjusted holiday
376
|| (
d
== 1 && m ==
March
)
377
// Children's Day
378
|| (
d
== 2 && m ==
April
)
379
// adjusted holiday
380
|| (
d
== 5 && m ==
April
)
381
// adjusted holiday
382
|| (
d
== 30 && m ==
April
)
383
// Dragon Boat Festival
384
|| (
d
== 14 && m ==
June
)
385
// adjusted holiday
386
|| (
d
== 20 && m ==
September
)
387
// Mid-Autumn Festival
388
|| (
d
== 21 && m ==
September
)
389
// adjusted holiday
390
|| (
d
== 11 && m ==
October
)
391
// adjusted holiday
392
|| (
d
== 31 && m ==
December
)
393
)
394
return
false
;
395
}
396
397
if
(
y
== 2022) {
398
// Mid-Autumn Festival falls on Saturday
399
if
(
// Lunar New Year
400
((
d
== 31 && m ==
January
) || (
d
<= 4 && m ==
February
))
401
// Children's Day
402
|| (
d
== 4 && m ==
April
)
403
// Tomb Sweeping Day
404
|| (
d
== 5 && m ==
April
)
405
// adjusted holiday
406
|| (
d
== 2 && m ==
May
)
407
// Dragon Boat Festival
408
|| (
d
== 3 && m ==
June
)
409
// adjusted holiday
410
|| (
d
== 9 && m ==
September
)
411
)
412
return
false
;
413
}
414
415
if
(
y
== 2023) {
416
if
(
// adjusted holiday
417
(
d
== 2 && m ==
January
)
418
// adjusted holiday
419
|| (
d
== 20 && m ==
January
)
420
// Lunar New Year
421
|| (
d
>= 21 &&
d
<= 24 && m ==
January
)
422
// adjusted holiday
423
|| (
d
>= 25 &&
d
<= 27 && m ==
January
)
424
// adjusted holiday
425
|| (
d
== 27 && m ==
February
)
426
// adjusted holiday
427
|| (
d
== 3 && m ==
April
)
428
// Children's Day
429
|| (
d
== 4 && m ==
April
)
430
// Tomb Sweeping Day
431
|| (
d
== 5 && m ==
April
)
432
// Dragon Boat Festival
433
|| (
d
== 22 && m ==
June
)
434
// adjusted holiday
435
|| (
d
== 23 && m ==
June
)
436
// Mid-Autumn Festival
437
|| (
d
== 29 && m ==
September
)
438
// adjusted holiday
439
|| (
d
== 9 && m ==
October
)
440
)
441
return
false
;
442
}
443
444
if
(
y
== 2024) {
445
if
(
// adjusted holiday
446
(
d
== 8 && m ==
February
)
447
// Lunar New Year
448
|| (
d
>= 9 &&
d
<= 12 && m ==
February
)
449
// adjusted holiday
450
|| (
d
>= 13 &&
d
<= 14 && m ==
February
)
451
// Children's Day
452
|| (
d
== 4 && m ==
April
)
453
// Tomb-sweeping Day
454
|| (
d
== 5 && m ==
April
)
455
// Dragon Boat Festival
456
|| (
d
== 10 && m ==
June
)
457
// Mid-autumn/Moon Festival
458
|| (
d
== 17 && m ==
September
)
459
)
460
return
false
;
461
}
462
463
return
true
;
464
}
465
466
}
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::Taiwan::TsecImpl
Definition:
taiwan.hpp:58
QuantLib::Taiwan::TsecImpl::isBusinessDay
bool isBusinessDay(const Date &) const override
Definition:
taiwan.cpp:36
QuantLib::Taiwan::TsecImpl::isWeekend
bool isWeekend(Weekday) const override
Definition:
taiwan.cpp:32
QuantLib::Taiwan::Taiwan
Taiwan(Market m=TSEC)
Definition:
taiwan.cpp:26
QuantLib::Taiwan::Market
Market
Definition:
taiwan.hpp:65
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::January
@ January
Definition:
date.hpp:57
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::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
taiwan.hpp
Taiwanese calendars.
Generated by
Doxygen
1.9.5