QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
indonesia.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, 2007, 2008, 2009, 2010, 2011 StatPro Italia 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 ext::shared_ptr<Calendar::Impl> bejImpl(
29 switch (market) {
30 case BEJ:
31 case JSX:
32 case IDX:
33 impl_ = bejImpl;
34 break;
35 default:
36 QL_FAIL("unknown market");
37 }
38 }
39
40 bool Indonesia::BejImpl::isBusinessDay(const Date& date) const {
41 Weekday w = date.weekday();
42 Day d = date.dayOfMonth();
43 Month m = date.month();
44 Year y = date.year();
45 Day dd = date.dayOfYear();
46 Day em = easterMonday(y);
47
48 if (isWeekend(w)
49 // New Year's Day
50 || (d == 1 && m == January)
51 // Good Friday
52 || (dd == em-3)
53 // Ascension Thursday
54 || (dd == em+38)
55 // Independence Day
56 || (d == 17 && m == August)
57 // Christmas
58 || (d == 25 && m == December)
59 )
60 return false;
61
62 if (y == 2005) {
63 if (// Idul Adha
64 (d == 21 && m == January)
65 // Imlek
66 || (d == 9 && m == February)
67 // Moslem's New Year Day
68 || (d == 10 && m == February)
69 // Nyepi
70 || (d == 11 && m == March)
71 // Birthday of Prophet Muhammad SAW
72 || (d == 22 && m == April)
73 // Waisak
74 || (d == 24 && m == May)
75 // Ascension of Prophet Muhammad SAW
76 || (d == 2 && m == September)
77 // Idul Fitri
78 || ((d == 3 || d == 4) && m == November)
79 // National leaves
80 || ((d == 2 || d == 7 || d == 8) && m == November)
81 || (d == 26 && m == December)
82 )
83 return false;
84 }
85
86 if (y == 2006) {
87 if (// Idul Adha
88 (d == 10 && m == January)
89 // Moslem's New Year Day
90 || (d == 31 && m == January)
91 // Nyepi
92 || (d == 30 && m == March)
93 // Birthday of Prophet Muhammad SAW
94 || (d == 10 && m == April)
95 // Ascension of Prophet Muhammad SAW
96 || (d == 21 && m == August)
97 // Idul Fitri
98 || ((d == 24 || d == 25) && m == October)
99 // National leaves
100 || ((d == 23 || d == 26 || d == 27) && m == October)
101 )
102 return false;
103 }
104
105 if (y == 2007) {
106 if (// Nyepi
107 (d == 19 && m == March)
108 // Waisak
109 || (d == 1 && m == June)
110 // Ied Adha
111 || (d == 20 && m == December)
112 // National leaves
113 || (d == 18 && m == May)
114 || ((d == 12 || d == 15 || d == 16) && m == October)
115 || ((d == 21 || d == 24) && m == October)
116 )
117 return false;
118 }
119
120 if (y == 2008) {
121 if (// Islamic New Year
122 ((d == 10 || d == 11) && m == January)
123 // Chinese New Year
124 || ((d == 7 || d == 8) && m == February)
125 // Saka's New Year
126 || (d == 7 && m == March)
127 // Birthday of the prophet Muhammad SAW
128 || (d == 20 && m == March)
129 // Vesak Day
130 || (d == 20 && m == May)
131 // Isra' Mi'raj of the prophet Muhammad SAW
132 || (d == 30 && m == July)
133 // National leave
134 || (d == 18 && m == August)
135 // Ied Fitr
136 || (d == 30 && m == September)
137 || ((d == 1 || d == 2 || d == 3) && m == October)
138 // Ied Adha
139 || (d == 8 && m == December)
140 // Islamic New Year
141 || (d == 29 && m == December)
142 // New Year's Eve
143 || (d == 31 && m == December)
144 )
145 return false;
146 }
147
148 if (y == 2009) {
149 if (// Public holiday
150 (d == 2 && m == January)
151 // Chinese New Year
152 || (d == 26 && m == January)
153 // Birthday of the prophet Muhammad SAW
154 || (d == 9 && m == March)
155 // Saka's New Year
156 || (d == 26 && m == March)
157 // National leave
158 || (d == 9 && m == April)
159 // Isra' Mi'raj of the prophet Muhammad SAW
160 || (d == 20 && m == July)
161 // Ied Fitr
162 || (d >= 18 && d <= 23 && m == September)
163 // Ied Adha
164 || (d == 27 && m == November)
165 // Islamic New Year
166 || (d == 18 && m == December)
167 // Public Holiday
168 || (d == 24 && m == December)
169 // Trading holiday
170 || (d == 31 && m == December)
171 )
172 return false;
173 }
174
175 if (y == 2010) {
176 if (// Birthday of the prophet Muhammad SAW
177 (d == 26 && m == February)
178 // Saka's New Year
179 || (d == 16 && m == March)
180 // Birth of Buddha
181 || (d == 28 && m == May)
182 // Ied Fitr
183 || (d >= 8 && d <= 14 && m == September)
184 // Ied Adha
185 || (d == 17 && m == November)
186 // Islamic New Year
187 || (d == 7 && m == December)
188 // Public Holiday
189 || (d == 24 && m == December)
190 // Trading holiday
191 || (d == 31 && m == December)
192 )
193 return false;
194 }
195
196 if (y == 2011) {
197 if (// Chinese New Year
198 (d == 3 && m == February)
199 // Birthday of the prophet Muhammad SAW
200 || (d == 15 && m == February)
201 // Birth of Buddha
202 || (d == 17 && m == May)
203 // Isra' Mi'raj of the prophet Muhammad SAW
204 || (d == 29 && m == June)
205 // Ied Fitr
206 || (d >= 29 && m == August)
207 || (d <= 2 && m == September)
208 // Public Holiday
209 || (d == 26 && m == December)
210 )
211 return false;
212 }
213
214 if (y == 2012) {
215 if (// Chinese New Year
216 (d == 23 && m == January)
217 // Saka New Year
218 || (d == 23 && m == March)
219 // Ied ul-Fitr
220 || (d >= 20 && d <= 22 && m == August)
221 // Eid ul-Adha
222 || (d == 26 && m == October)
223 // Islamic New Year
224 || (d >= 15 && d <= 16 && m == November)
225 // Public Holiday
226 || (d == 24 && m == December)
227 // Trading Holiday
228 || (d == 31 && m == December)
229 )
230 return false;
231 }
232
233 if (y == 2013) {
234 if (// Birthday of the prophet Muhammad SAW
235 (d == 24 && m == January)
236 // Saka New Year
237 || (d == 12 && m == March)
238 // Isra' Mi'raj of the prophet Muhammad SAW
239 || (d == 6 && m == June)
240 // Ied ul-Fitr
241 || (d >= 5 && d <= 9 && m == August)
242 // Eid ul-Adha
243 || (d >= 14 && d <= 15 && m == October)
244 // Islamic New Year
245 || (d == 5 && m == November)
246 // Public Holiday
247 || (d == 26 && m == December)
248 // Trading Holiday
249 || (d == 31 && m == December)
250 )
251 return false;
252 }
253
254 if (y == 2014) {
255 if (// Birthday of the prophet Muhammad SAW
256 (d == 14 && m == January)
257 // Chinese New Year
258 || (d == 31 && m == January)
259 // Saka New Year
260 || (d == 31 && m == March)
261 // Labour Day
262 || (d == 1 && m == May)
263 // Birth of Buddha
264 || (d == 15 && m == May)
265 // Isra' Mi'raj of the prophet Muhammad SAW
266 || (d == 27 && m == May)
267 // Ascension Day of Jesus Christ
268 || (d == 29 && m == May)
269 // Ied ul-Fitr
270 || ((d >= 28 && m == July) || (d == 1 && m == August))
271 // Public Holiday
272 || (d == 26 && m == December)
273 // Trading Holiday
274 || (d == 31 && m == December)
275 )
276 return false;
277 }
278
279 return true;
280 }
281
282}
283
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: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: indonesia.cpp:40
Indonesia(Market m=IDX)
Definition: indonesia.cpp:25
@ IDX
Indonesia stock exchange.
Definition: indonesia.hpp:72
@ BEJ
Jakarta stock exchange (merged into IDX)
Definition: indonesia.hpp:70
@ JSX
Jakarta stock exchange (merged into IDX)
Definition: indonesia.hpp:71
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
@ July
Definition: date.hpp:63
@ May
Definition: date.hpp:61
@ March
Definition: date.hpp:59
@ February
Definition: date.hpp:58
@ April
Definition: date.hpp:60
@ November
Definition: date.hpp:67
@ October
Definition: date.hpp:66
@ June
Definition: date.hpp:62
@ September
Definition: date.hpp:65
Indonesian calendars.
Definition: any.hpp:35