QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
time
calendars
thailand.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) 2018 Matthias Groncki
5
Copyright (C) 2023, 2024 Skandinaviska Enskilda Banken AB (publ)
6
7
This file is part of QuantLib, a free-software/open-source library
8
for financial quantitative analysts and developers - http://quantlib.org/
9
10
QuantLib is free software: you can redistribute it and/or modify it
11
under the terms of the QuantLib license. You should have received a
12
copy of the license along with this program; if not, please email
13
<quantlib-dev@lists.sf.net>. The license is also available online at
14
<http://quantlib.org/license.shtml>.
15
16
This program is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
FOR A PARTICULAR PURPOSE. See the license for more details.
19
*/
20
21
#include <
ql/time/calendars/thailand.hpp
>
22
23
namespace
QuantLib
{
24
25
Thailand::Thailand
() {
26
// all calendar instances share the same implementation instance
27
static
ext::shared_ptr<Calendar::Impl> impl(
new
Thailand::SetImpl
);
28
impl_
= impl;
29
}
30
31
bool
Thailand::SetImpl::isBusinessDay
(
const
Date
& date)
const
{
32
Weekday
w = date.
weekday
();
33
Day
d
= date.
dayOfMonth
();
34
Month
m = date.
month
();
35
Year
y
= date.
year
();
36
37
if
(
isWeekend
(w)
38
// New Year's Day
39
|| ((
d
== 1 || (
d
== 3 && w ==
Monday
)) && m ==
January
)
40
// Chakri Memorial Day
41
|| ((
d
== 6 || ((
d
== 7 ||
d
== 8) && w ==
Monday
)) && m ==
April
)
42
// Songkran Festival (was cancelled in 2020 due to the Covid-19 Pandamic)
43
|| ((
d
== 13 ||
d
== 14 ||
d
== 15) && m ==
April
&&
y
!= 2020)
44
// Substitution Songkran Festival, usually not more than 5 days in total (was cancelled
45
// in 2020 due to the Covid-19 Pandamic)
46
|| (
d
== 16 && (w ==
Monday
|| w ==
Tuesday
) && m ==
April
&&
y
!= 2020)
47
// Labor Day
48
|| ((
d
== 1 || ((
d
== 2 ||
d
== 3) && w ==
Monday
)) && m ==
May
)
49
// Coronation Day
50
|| ((
d
== 4 || ((
d
== 5 ||
d
== 6) && w ==
Monday
)) && m ==
May
&&
y
>= 2019)
51
// H.M.Queen Suthida Bajrasudhabimalalakshana’s Birthday
52
|| ((
d
== 03 || ((
d
== 04 ||
d
== 05) && w ==
Monday
)) && m ==
June
&&
y
>= 2019)
53
// H.M. King Maha Vajiralongkorn Phra Vajiraklaochaoyuhua’s Birthday
54
|| ((
d
== 28 || ((
d
== 29 ||
d
== 30) && w ==
Monday
)) && m ==
July
&&
y
>= 2017)
55
// H.M. Queen Sirikit The Queen Mother’s Birthday / Mother’s Day
56
|| ((
d
== 12 || ((
d
== 13 ||
d
== 14) && w ==
Monday
)) && m ==
August
)
57
// H.M. King Bhumibol Adulyadej The Great Memorial Day
58
|| ((
d
== 13 || ((
d
== 14 ||
d
== 15) && w ==
Monday
)) && m ==
October
&&
y
>= 2017)
59
// Chulalongkorn Day
60
|| ((
d
== 23 || ((
d
== 24 ||
d
== 25) && w ==
Monday
)) && m ==
October
&&
y
!= 2021)
// Moved 2021, see below
61
// H.M. King Bhumibol Adulyadej The Great’s Birthday/ National Day / Father’s Day
62
|| ((
d
== 5 || ((
d
== 6 ||
d
== 7) && w ==
Monday
)) && m ==
December
)
63
// Constitution Day
64
|| ((
d
== 10 || ((
d
== 11 ||
d
== 12) && w ==
Monday
)) && m ==
December
)
65
// New Year’s Eve
66
|| ((
d
== 31 && m ==
December
) || (
d
== 2 && w ==
Monday
&& m ==
January
&&
y
!= 2024))
// Moved 2024
67
)
68
return
false
;
69
70
if
((
y
== 2000) &&
71
( (
d
==21 && m==
February
)
// Makha Bucha Day (Substitution Day)
72
|| (
d
==5 && m==
May
)
// Coronation Day
73
|| (
d
==17 && m==
May
)
// Wisakha Bucha Day
74
|| (
d
==17 && m==
July
)
// Buddhist Lent Day
75
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
76
))
77
return
false
;
78
79
if
((
y
== 2001) &&
80
( (
d
==8 && m==
February
)
// Makha Bucha Day
81
|| (
d
==7 && m==
May
)
// Wisakha Bucha Day
82
|| (
d
==8 && m==
May
)
// Coronation Day (Substitution Day)
83
|| (
d
==6 && m==
July
)
// Buddhist Lent Day
84
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
85
))
86
return
false
;
87
88
// 2002, 2003 and 2004 are missing
89
90
if
((
y
== 2005) &&
91
( (
d
==23 && m==
February
)
// Makha Bucha Day
92
|| (
d
==5 && m==
May
)
// Coronation Day
93
|| (
d
==23 && m==
May
)
// Wisakha Bucha Day (Substitution Day for Sunday 22 May)
94
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
95
|| (
d
==22 && m==
July
)
// Buddhist Lent Day
96
|| (
d
==24 && m==
October
)
// Chulalongkorn Day (Substitution Day for Sunday 23 October)
97
))
98
return
false
;
99
100
if
((
y
== 2006) &&
101
( (
d
==13 && m==
February
)
// Makha Bucha Day
102
|| (
d
==19 && m==
April
)
// Special Holiday
103
|| (
d
==5 && m==
May
)
// Coronation Day
104
|| (
d
==12 && m==
May
)
// Wisakha Bucha Day
105
|| (
d
==12 && m==
June
)
// Special Holidays (Due to the auspicious occasion of the
106
// celebration of 60th Anniversary of His Majesty's Accession
107
// to the throne. For Bangkok, Samut Prakan, Nonthaburi,
108
// Pathumthani and Nakhon Pathom province)
109
|| (
d
==13 && m==
June
)
// Special Holidays (as above)
110
|| (
d
==11 && m==
July
)
// Buddhist Lent Day
111
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
112
))
113
return
false
;
114
115
if
((
y
== 2007) &&
116
( (
d
==5 && m==
March
)
// Makha Bucha Day (Substitution Day for Saturday 3 March)
117
|| (
d
==7 && m==
May
)
// Coronation Day (Substitution Day for Saturday 5 May)
118
|| (
d
==31 && m==
May
)
// Wisakha Bucha Day
119
|| (
d
==30 && m==
July
)
// Asarnha Bucha Day (Substitution Day for Sunday 29 July)
120
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
121
|| (
d
==24 && m==
December
)
// Special Holiday
122
))
123
return
false
;
124
125
if
((
y
== 2008) &&
126
( (
d
==21 && m==
February
)
// Makha Bucha Day
127
|| (
d
==5 && m==
May
)
// Coronation Day
128
|| (
d
==19 && m==
May
)
// Wisakha Bucha Day
129
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
130
|| (
d
==17 && m==
July
)
// Asarnha Bucha Day
131
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
132
))
133
return
false
;
134
135
if
((
y
== 2009) &&
136
( (
d
==2 && m==
January
)
// Special Holiday
137
|| (
d
==9 && m==
February
)
// Makha Bucha Day
138
|| (
d
==5 && m==
May
)
// Coronation Day
139
|| (
d
==8 && m==
May
)
// Wisakha Bucha Day
140
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
141
|| (
d
==6 && m==
July
)
// Special Holiday
142
|| (
d
==7 && m==
July
)
// Asarnha Bucha Day
143
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
144
))
145
return
false
;
146
147
if
((
y
== 2010) &&
148
( (
d
==1 && m==
March
)
// Substitution for Makha Bucha Day(Sunday 28 February)
149
|| (
d
==5 && m==
May
)
// Coronation Day
150
|| (
d
==20 && m==
May
)
// Special Holiday
151
|| (
d
==21 && m==
May
)
// Special Holiday
152
|| (
d
==28 && m==
May
)
// Wisakha Bucha Day
153
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
154
|| (
d
==26 && m==
July
)
// Asarnha Bucha Day
155
|| (
d
==13 && m==
August
)
// Special Holiday
156
|| (
d
==25 && m==
October
)
// Substitution for Chulalongkorn Day(Saturday 23 October)
157
))
158
return
false
;
159
160
if
((
y
== 2011) &&
161
( (
d
==18 && m==
February
)
// Makha Bucha Day
162
|| (
d
==5 && m==
May
)
// Coronation Day
163
|| (
d
==16 && m==
May
)
// Special Holiday
164
|| (
d
==17 && m==
May
)
// Wisakha Bucha Day
165
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
166
|| (
d
==15 && m==
July
)
// Asarnha Bucha Day
167
|| (
d
==24 && m==
October
)
// Substitution for Chulalongkorn Day(Sunday 23 October)
168
))
169
return
false
;
170
171
if
((
y
== 2012) &&
172
( (
d
==3 && m==
January
)
// Special Holiday
173
|| (
d
==7 && m==
March
)
// Makha Bucha Day 2/
174
|| (
d
==9 && m==
April
)
// Special Holiday
175
|| (
d
==7 && m==
May
)
// Substitution for Coronation Day(Saturday 5 May)
176
|| (
d
==4 && m==
June
)
// Wisakha Bucha Day
177
|| (
d
==2 && m==
August
)
// Asarnha Bucha Day
178
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
179
))
180
return
false
;
181
182
if
((
y
== 2013) &&
183
( (
d
==25 && m==
February
)
// Makha Bucha Day
184
|| (
d
==6 && m==
May
)
// Substitution for Coronation Day(Sunday 5 May)
185
|| (
d
==24 && m==
May
)
// Wisakha Bucha Day
186
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
187
|| (
d
==22 && m==
July
)
// Asarnha Bucha Day 2/
188
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
189
|| (
d
==30 && m==
December
)
// Special Holiday
190
))
191
return
false
;
192
193
if
((
y
== 2014) &&
194
( (
d
==14 && m==
February
)
// Makha Bucha Day
195
|| (
d
==5 && m==
May
)
// Coronation Day
196
|| (
d
==13 && m==
May
)
// Wisakha Bucha Day
197
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
198
|| (
d
==11 && m==
July
)
// Asarnha Bucha Day 1/
199
|| (
d
==11 && m==
August
)
// Special Holiday
200
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
201
))
202
return
false
;
203
204
if
((
y
== 2015) &&
205
( (
d
==2 && m==
January
)
// Special Holiday
206
|| (
d
==4 && m==
March
)
// Makha Bucha Day
207
|| (
d
==4 && m==
May
)
// Special Holiday
208
|| (
d
==5 && m==
May
)
// Coronation Day
209
|| (
d
==1 && m==
June
)
// Wisakha Bucha Day
210
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
211
|| (
d
==30 && m==
July
)
// Asarnha Bucha Day 1/
212
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
213
))
214
return
false
;
215
216
if
((
y
== 2016) &&
217
( (
d
==22 && m==
February
)
// Makha Bucha Day
218
|| (
d
==5 && m==
May
)
// Coronation Day
219
|| (
d
==6 && m==
May
)
// Special Holiday
220
|| (
d
==20 && m==
May
)
// Wisakha Bucha Day
221
|| (
d
==1 && m==
July
)
// Mid Year Closing Day
222
|| (
d
==18 && m==
July
)
// Special Holiday
223
|| (
d
==19 && m==
July
)
// Asarnha Bucha Day 1/
224
|| (
d
==24 && m==
October
)
// Substitution for Chulalongkorn Day (Sunday 23rd October)
225
))
226
return
false
;
227
228
if
((
y
== 2017) &&
229
( (
d
== 13 && m ==
February
)
// Makha Bucha Day
230
|| (
d
== 10 && m ==
May
)
// Wisakha Bucha Day
231
|| (
d
== 10 && m ==
July
)
// Asarnha Bucha Day
232
|| (
d
== 23 && m ==
October
)
// Chulalongkorn Day
233
|| (
d
== 26 && m ==
October
)
// Special Holiday
234
))
235
return
false
;
236
237
if
((
y
== 2018) &&
238
( (
d
==1 && m==
March
)
// Makha Bucha Day
239
|| (
d
==29 && m==
May
)
// Wisakha Bucha Day
240
|| (
d
==27 && m==
July
)
// Asarnha Bucha Day1
241
|| (
d
==23 && m==
October
)
// Chulalongkorn Day
242
))
243
return
false
;
244
245
if
((
y
== 2019) && ((
d
== 19 && m ==
February
)
// Makha Bucha Day
246
|| (
d
== 6 && m ==
May
)
// Special Holiday
247
|| (
d
== 20 && m ==
May
)
// Wisakha Bucha Day
248
|| (
d
== 16 && m ==
July
)
// Asarnha Bucha Day
249
))
250
return
false
;
251
252
if
((
y
== 2020) && ((
d
== 10 && m ==
February
)
// Makha Bucha Day
253
|| (
d
== 6 && m ==
May
)
// Wisakha Bucha Day
254
|| (
d
== 6 && m ==
July
)
// Asarnha Bucha Day
255
|| (
d
== 27 && m ==
July
)
// Substitution for Songkran Festival
256
|| (
d
== 4 && m ==
September
)
// Substitution for Songkran Festival
257
|| (
d
== 7 && m ==
September
)
// Substitution for Songkran Festival
258
|| (
d
== 11 && m ==
December
)
// Special Holiday
259
))
260
return
false
;
261
262
if
((
y
== 2021) && ((
d
== 12 && m ==
February
)
// Special Holiday
263
|| (
d
== 26 && m ==
February
)
// Makha Bucha Day
264
|| (
d
== 26 && m ==
May
)
// Wisakha Bucha Day
265
|| (
d
== 26 && m ==
July
)
// Substitution for Asarnha Bucha Day (Saturday 24th July 2021)
266
|| (
d
== 24 && m ==
September
)
// Special Holiday
267
|| (
d
== 22 && m ==
October
)
// Substitution for Chulalongkorn Day
268
))
269
return
false
;
270
271
if
((
y
== 2022) && ((
d
== 16 && m ==
February
)
// Makha Bucha Day
272
|| (
d
== 16 && m ==
May
)
// Substitution for Wisakha Bucha Day (Sunday 15th May 2022)
273
|| (
d
== 13 && m ==
July
)
// Asarnha Bucha Day
274
|| (
d
== 29 && m ==
July
)
// Additional special holiday (added)
275
|| (
d
== 14 && m ==
October
)
// Additional special holiday (added)
276
|| (
d
== 24 && m ==
October
)
// Substitution for Chulalongkorn Day (Sunday 23rd October 2022)
277
))
278
return
false
;
279
280
if
((
y
== 2023) && ((
d
== 6 && m ==
March
)
// Makha Bucha Day
281
|| (
d
== 5 && m ==
May
)
// Additional special holiday (added)
282
|| (
d
== 5 && m ==
June
)
// Substitution for H.M. Queen's birthday and Wisakha Bucha Day (Saturday 3rd June 2022)
283
|| (
d
== 1 && m ==
August
)
// Asarnha Bucha Day
284
|| (
d
== 23 && m ==
October
)
// Chulalongkorn Day
285
|| (
d
== 29 && m ==
December
)
// Substitution for New Year’s Eve (Sunday 31st December 2023) (added)
286
))
287
return
false
;
288
289
if
((
y
== 2024) && ((
d
== 26 && m ==
February
)
// Substitution for Makha Bucha Day (Saturday 24th February 2024)
290
|| (
d
== 8 && m ==
April
)
// Substitution for Chakri Memorial Day (Saturday 6th April 2024)
291
|| (
d
== 12 && m ==
April
)
// Additional holiday in relation to the Songkran festival
292
|| (
d
== 6 && m ==
May
)
// Substitution for Coronation Day (Saturday 4th May 2024)
293
|| (
d
== 22 && m ==
May
)
// Wisakha Bucha Day
294
|| (
d
== 22 && m ==
July
)
// Substitution for Asarnha Bucha Day (Saturday 20th July 2024)
295
|| (
d
== 23 && m ==
October
)
// Chulalongkorn Day
296
))
297
return
false
;
298
299
return
true
;
300
}
301
302
}
y
Real y
Definition:
andreasenhugevolatilityinterpl.cpp:46
QuantLib::Calendar::WesternImpl::isWeekend
bool isWeekend(Weekday) const override
Definition:
calendar.cpp:195
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::Thailand::SetImpl
Definition:
thailand.hpp:71
QuantLib::Thailand::SetImpl::isBusinessDay
bool isBusinessDay(const Date &) const override
Definition:
thailand.cpp:31
QuantLib::Thailand::Thailand
Thailand()
Definition:
thailand.cpp:25
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::October
@ October
Definition:
date.hpp:66
QuantLib::June
@ June
Definition:
date.hpp:62
QuantLib::September
@ September
Definition:
date.hpp:65
QuantLib::Monday
@ Monday
Definition:
weekday.hpp:42
QuantLib::Tuesday
@ Tuesday
Definition:
weekday.hpp:43
QuantLib
Definition:
any.hpp:35
thailand.hpp
Thailand calendars.
Generated by
Doxygen
1.9.5