-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcalendars.i
285 lines (237 loc) · 7.44 KB
/
calendars.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#ifndef quantlib_calendar_i
#define quantlib_calendar_i
%include common.i
%include date.i
%include stl.i
%define QL_TYPECHECK_BUSINESSDAYCONVENTION 6210 %enddef
%{
using QuantLib::Calendar;
%}
%{
using QuantLib::BusinessDayConvention;
using QuantLib::Following;
using QuantLib::ModifiedFollowing;
using QuantLib::Preceding;
using QuantLib::ModifiedPreceding;
using QuantLib::Unadjusted;
using QuantLib::HalfMonthModifiedFollowing;
%}
enum BusinessDayConvention {
Following,
ModifiedFollowing,
Preceding,
ModifiedPreceding,
Unadjusted,
HalfMonthModifiedFollowing
};
%{
using QuantLib::JointCalendarRule;
using QuantLib::JoinHolidays;
using QuantLib::JoinBusinessDays;
%}
enum JointCalendarRule { JoinHolidays, JoinBusinessDays };
%typemap(in) boost::optional<BusinessDayConvention> %{
if($input == Py_None)
$1 = boost::none;
else if (PyInt_Check($input))
$1 = (BusinessDayConvention) PyInt_AsLong($input);
else
$1 = (BusinessDayConvention) PyLong_AsLong($input);
%}
%typecheck (QL_TYPECHECK_BUSINESSDAYCONVENTION) boost::optional<BusinessDayConvention> {
if (PyInt_Check($input) || PyLong_Check($input) || Py_None == $input)
$1 = 1;
else
$1 = 0;
}
class Calendar {
protected:
Calendar();
public:
bool isWeekend(Weekday w);
Date endOfMonth(const Date&);
bool isBusinessDay(const Date&);
bool isHoliday(const Date&);
bool isEndOfMonth(const Date&);
void addHoliday(const Date&);
void removeHoliday(const Date&);
Date adjust(const Date& d,
BusinessDayConvention convention = QuantLib::Following);
Date advance(const Date& d, Integer n, TimeUnit unit,
BusinessDayConvention convention = QuantLib::Following,
bool endOfMonth = false);
Date advance(const Date& d, const Period& period,
BusinessDayConvention convention = QuantLib::Following,
bool endOfMonth = false);
BigInteger businessDaysBetween(const Date& from,
const Date& to,
bool includeFirst = true,
bool includeLast = false);
static std::vector<Date> holidayList(const Calendar& calendar,
const Date& from,
const Date& to,
bool includeWeekEnds = false);
std::string name();
%extend {
std::string __str__() {
return self->name()+" calendar";
}
bool __eq__(const Calendar& other) {
return (*self) == other;
}
bool __ne__(const Calendar& other) {
return (*self) != other;
}
}
%pythoncode %{
def __hash__(self):
return hash(self.name())
%}
};
namespace QuantLib {
class Argentina : public Calendar {
public:
enum Market { Merval };
Argentina(Market m = Merval);
};
class Australia : public Calendar {};
class Brazil : public Calendar {
public:
enum Market { Settlement, Exchange };
Brazil(Market m = Settlement);
};
class Canada : public Calendar {
public:
enum Market { Settlement, TSX };
Canada(Market m = Settlement);
};
class China : public Calendar {
public:
enum Market { SSE, IB };
China(Market m = SSE);
};
class CzechRepublic : public Calendar {
public:
enum Market { PSE };
CzechRepublic(Market m = PSE);
};
class Denmark : public Calendar {};
class Finland : public Calendar {};
class Germany : public Calendar {
public:
enum Market { Settlement, FrankfurtStockExchange, Xetra, Eurex };
Germany(Market m = FrankfurtStockExchange);
};
class HongKong : public Calendar {
public:
enum Market { HKEx };
HongKong(Market m = HKEx);
};
class Hungary : public Calendar {};
class Iceland : public Calendar {
public:
enum Market { ICEX };
Iceland(Market m = ICEX);
};
class India : public Calendar {
public:
enum Market { NSE };
India(Market m = NSE);
};
class Indonesia : public Calendar {
public:
enum Market { BEJ, JSX };
Indonesia(Market m = BEJ);
};
class Israel : public Calendar {
public:
enum Market { Settlement, TASE };
Israel(Market m = Settlement);
};
class Italy : public Calendar {
public:
enum Market { Settlement, Exchange };
Italy(Market m = Settlement);
};
class Japan : public Calendar {};
class Mexico : public Calendar {
public:
enum Market { BMV };
Mexico(Market m = BMV);
};
class NewZealand : public Calendar {};
class Norway : public Calendar {};
class Poland : public Calendar {};
class Russia : public Calendar {
public:
enum Market { Settlement, MOEX };
Russia(Market m = Settlement);
};
class Romania : public Calendar {};
class SaudiArabia : public Calendar {
public:
enum Market { Tadawul };
SaudiArabia(Market m = Tadawul);
};
class Singapore : public Calendar {
public:
enum Market { SGX };
Singapore(Market m = SGX);
};
class Slovakia : public Calendar {
public:
enum Market { BSSE };
Slovakia(Market m = BSSE);
};
class SouthAfrica : public Calendar {};
class SouthKorea : public Calendar {
public:
enum Market { Settlement, KRX };
SouthKorea(Market m = KRX);
};
class Sweden : public Calendar {};
class Switzerland : public Calendar {};
class Taiwan : public Calendar {
public:
enum Market { TSEC };
Taiwan(Market m = TSEC);
};
class TARGET : public Calendar {};
class Thailand : public Calendar {};
class Turkey : public Calendar {};
class Ukraine : public Calendar {
public:
enum Market { USE };
Ukraine(Market m = USE);
};
class UnitedKingdom : public Calendar {
public:
enum Market { Settlement, Exchange, Metals };
UnitedKingdom(Market m = Settlement);
};
class UnitedStates : public Calendar {
public:
enum Market { Settlement, NYSE, GovernmentBond,
NERC, LiborImpact, FederalReserve };
UnitedStates(Market m = Settlement);
};
// others
class NullCalendar : public Calendar {};
class WeekendsOnly : public Calendar {};
class JointCalendar : public Calendar {
public:
JointCalendar(const Calendar&, const Calendar&,
JointCalendarRule rule = QuantLib::JoinHolidays);
JointCalendar(const Calendar&, const Calendar&, const Calendar&,
JointCalendarRule rule = QuantLib::JoinHolidays);
JointCalendar(const Calendar&, const Calendar&,
const Calendar&, const Calendar&,
JointCalendarRule rule = QuantLib::JoinHolidays);
};
class BespokeCalendar : public Calendar {
public:
BespokeCalendar(const std::string& name);
void addWeekend(Weekday);
};
}
#endif //quantlib_calendar_i