Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
indices.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <boost/test/unit_test.hpp>
22#include <oret/toplevelfixture.hpp>
23
24using namespace QuantLib;
25using namespace boost::unit_test_framework;
26using namespace ore;
27using namespace std;
28
29namespace {
30
31QuantLib::ext::shared_ptr<data::Conventions> convs() {
32 QuantLib::ext::shared_ptr<data::Conventions> conventions(new data::Conventions());
33 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexEURConv(
34 new ore::data::SwapIndexConvention("EUR-CMS-2Y", "EUR-6M-SWAP-CONVENTIONS"));
35 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexEURLongConv(
36 new ore::data::SwapIndexConvention("EUR-CMS-30Y", "EUR-6M-SWAP-CONVENTIONS"));
37 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexUSDConv(
38 new ore::data::SwapIndexConvention("USD-CMS-2Y", "USD-3M-SWAP-CONVENTIONS"));
39 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexUSDLongConv(
40 new ore::data::SwapIndexConvention("USD-CMS-30Y", "USD-3M-SWAP-CONVENTIONS"));
41 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexGBPConv(
42 new ore::data::SwapIndexConvention("GBP-CMS-2Y", "GBP-3M-SWAP-CONVENTIONS"));
43 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexGBPLongConv(
44 new ore::data::SwapIndexConvention("GBP-CMS-30Y", "GBP-6M-SWAP-CONVENTIONS"));
45 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexCHFConv(
46 new ore::data::SwapIndexConvention("CHF-CMS-2Y", "CHF-3M-SWAP-CONVENTIONS"));
47 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexCHFLongConv(
48 new ore::data::SwapIndexConvention("CHF-CMS-30Y", "CHF-6M-SWAP-CONVENTIONS"));
49 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexJPYConv(
50 new ore::data::SwapIndexConvention("JPY-CMS-2Y", "JPY-LIBOR-6M-SWAP-CONVENTIONS"));
51 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexJPYLongConv(
52 new ore::data::SwapIndexConvention("JPY-CMS-30Y", "JPY-LIBOR-6M-SWAP-CONVENTIONS"));
53
54 conventions->add(swapIndexEURConv);
55 conventions->add(swapIndexEURLongConv);
56 conventions->add(swapIndexUSDConv);
57 conventions->add(swapIndexUSDLongConv);
58 conventions->add(swapIndexGBPConv);
59 conventions->add(swapIndexGBPLongConv);
60 conventions->add(swapIndexCHFConv);
61 conventions->add(swapIndexCHFLongConv);
62 conventions->add(swapIndexJPYConv);
63 conventions->add(swapIndexJPYLongConv);
64
65 QuantLib::ext::shared_ptr<ore::data::Convention> swapEURConv(new ore::data::IRSwapConvention(
66 "EUR-6M-SWAP-CONVENTIONS", "TARGET", "Annual", "MF", "30/360 (Bond Basis)", "EUR-EURIBOR-6M"));
67 QuantLib::ext::shared_ptr<ore::data::Convention> swapUSDConv(
68 new ore::data::IRSwapConvention("USD-3M-SWAP-CONVENTIONS", "US", "Semiannual", "MF", "30/360 (Bond Basis)", "USD-LIBOR-3M"));
69 QuantLib::ext::shared_ptr<ore::data::Convention> swapGBPConv(
70 new ore::data::IRSwapConvention("GBP-3M-SWAP-CONVENTIONS", "UK", "Semiannual", "MF", "A365", "GBP-LIBOR-3M"));
71 QuantLib::ext::shared_ptr<ore::data::Convention> swapGBPLongConv(
72 new ore::data::IRSwapConvention("GBP-6M-SWAP-CONVENTIONS", "UK", "Semiannual", "MF", "A365", "GBP-LIBOR-6M"));
73 QuantLib::ext::shared_ptr<ore::data::Convention> swapCHFConv(
74 new ore::data::IRSwapConvention("CHF-3M-SWAP-CONVENTIONS", "ZUB", "Annual", "MF", "30/360 (Bond Basis)", "CHF-LIBOR-3M"));
75 QuantLib::ext::shared_ptr<ore::data::Convention> swapCHFLongConv(
76 new ore::data::IRSwapConvention("CHF-6M-SWAP-CONVENTIONS", "ZUB", "Annual", "MF", "30/360 (Bond Basis)", "CHF-LIBOR-6M"));
77 QuantLib::ext::shared_ptr<ore::data::Convention> swapJPYConv(new ore::data::IRSwapConvention(
78 "JPY-LIBOR-6M-SWAP-CONVENTIONS", "JP", "Semiannual", "MF", "A365", "JPY-LIBOR-6M"));
79
80 conventions->add(swapEURConv);
81 conventions->add(swapUSDConv);
82 conventions->add(swapGBPConv);
83 conventions->add(swapGBPLongConv);
84 conventions->add(swapCHFConv);
85 conventions->add(swapCHFLongConv);
86 conventions->add(swapJPYConv);
87
88 return conventions;
89}
90
91struct test_data {
92 const char* str;
93 const char* index_name;
94 Period tenor;
95};
96
97struct test_data_inf {
98 const char* str;
99 const char* index_name;
100 Frequency frequency;
101};
102
103static struct test_data index_data[] = {
104 // parsing string, index name, tenor
105 {"EUR-EONIA-1D", "EoniaON Actual/360", 1 * Days},
106 {"EUR-ESTER", "ESTRON Actual/360", 1 * Days},
107 {"GBP-SONIA-1D", "SoniaON Actual/365 (Fixed)", 1 * Days},
108 {"JPY-TONAR-1D", "TONARON Actual/365 (Fixed)", 1 * Days},
109 {"CHF-TOIS", "CHF-TOISTN Actual/360", 1 * Days},
110 {"USD-FedFunds", "FedFundsON Actual/360", 1 * Days},
111 {"USD-SOFR", "SOFRON Actual/360", 1 * Days},
112 {"CHF-SARON", "CHF-SARONON Actual/360", 1 * Days},
113 {"DKK-DKKOIS", "DKK-DKKOISTN Actual/360", 1 * Days},
114 {"SEK-SIOR", "SEK-SIORTN Actual/360", 1 * Days},
115 {"NOK-NOWA", "NowaON Actual/Actual (ISMA)", 1 * Days},
116 {"NZD-OCR", "NzocrON Actual/365 (Fixed)", 1 * Days},
117 {"BRL-CDI", "BRL-CDION Business/252(Brazil)", 1 * Days},
118 {"INR-MIBOROIS", "INR-MIBOROISON Actual/365 (Fixed)", 1 * Days},
119
120 {"AUD-LIBOR-1W", "AUDLibor1W Actual/360", 1 * Weeks},
121 {"AUD-LIBOR-1M", "AUDLibor1M Actual/360", 1 * Months},
122 {"AUD-LIBOR-2M", "AUDLibor2M Actual/360", 2 * Months},
123 {"AUD-LIBOR-3M", "AUDLibor3M Actual/360", 3 * Months},
124 {"AUD-LIBOR-6M", "AUDLibor6M Actual/360", 6 * Months},
125 {"AUD-LIBOR-12M", "AUDLibor1Y Actual/360", 1 * Years},
126 {"AUD-LIBOR-1Y", "AUDLibor1Y Actual/360", 1 * Years},
127
128 {"AUD-BBSW-1W", "Bbsw1W Actual/365 (Fixed)", 1 * Weeks},
129 {"AUD-BBSW-1M", "Bbsw1M Actual/365 (Fixed)", 1 * Months},
130 {"AUD-BBSW-2M", "Bbsw2M Actual/365 (Fixed)", 2 * Months},
131 {"AUD-BBSW-3M", "Bbsw3M Actual/365 (Fixed)", 3 * Months},
132 {"AUD-BBSW-6M", "Bbsw6M Actual/365 (Fixed)", 6 * Months},
133 {"AUD-BBSW-12M", "Bbsw1Y Actual/365 (Fixed)", 1 * Years},
134 {"AUD-BBSW-1Y", "Bbsw1Y Actual/365 (Fixed)", 1 * Years},
135
136 {"EUR-EURIBOR-1W", "Euribor1W Actual/360", 1 * Weeks},
137 {"EUR-EURIBOR-2W", "Euribor2W Actual/360", 2 * Weeks},
138 {"EUR-EURIBOR-3W", "Euribor3W Actual/360", 3 * Weeks},
139 {"EUR-EURIBOR-1M", "Euribor1M Actual/360", 1 * Months},
140 {"EUR-EURIBOR-2M", "Euribor2M Actual/360", 2 * Months},
141 {"EUR-EURIBOR-3M", "Euribor3M Actual/360", 3 * Months},
142 {"EUR-EURIBOR-4M", "Euribor4M Actual/360", 4 * Months},
143 {"EUR-EURIBOR-5M", "Euribor5M Actual/360", 5 * Months},
144 {"EUR-EURIBOR-6M", "Euribor6M Actual/360", 6 * Months},
145 {"EUR-EURIBOR-7M", "Euribor7M Actual/360", 7 * Months},
146 {"EUR-EURIBOR-8M", "Euribor8M Actual/360", 8 * Months},
147 {"EUR-EURIBOR-9M", "Euribor9M Actual/360", 9 * Months},
148 {"EUR-EURIBOR-10M", "Euribor10M Actual/360", 10 * Months},
149 {"EUR-EURIBOR-11M", "Euribor11M Actual/360", 11 * Months},
150 {"EUR-EURIBOR-12M", "Euribor1Y Actual/360", 1 * Years},
151 {"EUR-EURIBOR-1Y", "Euribor1Y Actual/360", 1 * Years},
152
153 {"EUR-LIBOR-1W", "EURLibor1W Actual/360", 1 * Weeks},
154 {"EUR-LIBOR-1M", "EURLibor1M Actual/360", 1 * Months},
155 {"EUR-LIBOR-2M", "EURLibor2M Actual/360", 2 * Months},
156 {"EUR-LIBOR-3M", "EURLibor3M Actual/360", 3 * Months},
157 {"EUR-LIBOR-6M", "EURLibor6M Actual/360", 6 * Months},
158 {"EUR-LIBOR-12M", "EURLibor1Y Actual/360", 1 * Years},
159 {"EUR-LIBOR-1Y", "EURLibor1Y Actual/360", 1 * Years},
160
161 {"CAD-CDOR-1W", "CDOR1W Actual/365 (Fixed)", 1 * Weeks},
162 {"CAD-CDOR-1M", "CDOR1M Actual/365 (Fixed)", 1 * Months},
163 {"CAD-CDOR-2M", "CDOR2M Actual/365 (Fixed)", 2 * Months},
164 {"CAD-CDOR-3M", "CDOR3M Actual/365 (Fixed)", 3 * Months},
165 {"CAD-CDOR-6M", "CDOR6M Actual/365 (Fixed)", 6 * Months},
166 {"CAD-CDOR-12M", "CDOR1Y Actual/365 (Fixed)", 1 * Years},
167 {"CAD-CDOR-1Y", "CDOR1Y Actual/365 (Fixed)", 1 * Years},
168
169 {"CAD-BA-1W", "CDOR1W Actual/365 (Fixed)", 1 * Weeks},
170 {"CAD-BA-1M", "CDOR1M Actual/365 (Fixed)", 1 * Months},
171 {"CAD-BA-2M", "CDOR2M Actual/365 (Fixed)", 2 * Months},
172 {"CAD-BA-3M", "CDOR3M Actual/365 (Fixed)", 3 * Months},
173 {"CAD-BA-6M", "CDOR6M Actual/365 (Fixed)", 6 * Months},
174 {"CAD-BA-12M", "CDOR1Y Actual/365 (Fixed)", 1 * Years},
175 {"CAD-BA-1Y", "CDOR1Y Actual/365 (Fixed)", 1 * Years},
176
177 {"CNY-SHIBOR-3M", "Shibor3M Actual/360", 3 * Months},
178 {"CNY-REPOFIX-1D", "CNY-REPOFIXTN Actual/365 (Fixed)", 1 * Days},
179 {"CNY-REPOFIX-7D", "CNY-REPOFIX1W Actual/365 (Fixed)", 1 * Weeks},
180 {"CNY-REPOFIX-1W", "CNY-REPOFIX1W Actual/365 (Fixed)", 1 * Weeks},
181 {"CNY-REPOFIX-14D", "CNY-REPOFIX2W Actual/365 (Fixed)", 2 * Weeks},
182 {"CNY-REPOFIX-2W", "CNY-REPOFIX2W Actual/365 (Fixed)", 2 * Weeks},
183
184 {"CZK-PRIBOR-6M", "CZK-PRIBOR6M Actual/360", 6 * Months},
185
186 {"USD-LIBOR-1W", "USDLibor1W Actual/360", 1 * Weeks},
187 {"USD-LIBOR-1M", "USDLibor1M Actual/360", 1 * Months},
188 {"USD-LIBOR-2M", "USDLibor2M Actual/360", 2 * Months},
189 {"USD-LIBOR-3M", "USDLibor3M Actual/360", 3 * Months},
190 {"USD-LIBOR-6M", "USDLibor6M Actual/360", 6 * Months},
191 {"USD-LIBOR-12M", "USDLibor1Y Actual/360", 1 * Years},
192 {"USD-LIBOR-1Y", "USDLibor1Y Actual/360", 1 * Years},
193
194 {"GBP-LIBOR-1W", "GBPLibor1W Actual/365 (Fixed)", 1 * Weeks},
195 {"GBP-LIBOR-1M", "GBPLibor1M Actual/365 (Fixed)", 1 * Months},
196 {"GBP-LIBOR-2M", "GBPLibor2M Actual/365 (Fixed)", 2 * Months},
197 {"GBP-LIBOR-3M", "GBPLibor3M Actual/365 (Fixed)", 3 * Months},
198 {"GBP-LIBOR-6M", "GBPLibor6M Actual/365 (Fixed)", 6 * Months},
199 {"GBP-LIBOR-12M", "GBPLibor1Y Actual/365 (Fixed)", 1 * Years},
200 {"GBP-LIBOR-1Y", "GBPLibor1Y Actual/365 (Fixed)", 1 * Years},
201
202 {"JPY-LIBOR-1W", "JPYLibor1W Actual/360", 1 * Weeks},
203 {"JPY-LIBOR-1M", "JPYLibor1M Actual/360", 1 * Months},
204 {"JPY-LIBOR-2M", "JPYLibor2M Actual/360", 2 * Months},
205 {"JPY-LIBOR-3M", "JPYLibor3M Actual/360", 3 * Months},
206 {"JPY-LIBOR-6M", "JPYLibor6M Actual/360", 6 * Months},
207 {"JPY-LIBOR-12M", "JPYLibor1Y Actual/360", 1 * Years},
208 {"JPY-LIBOR-1Y", "JPYLibor1Y Actual/360", 1 * Years},
209
210 {"JPY-TIBOR-1W", "Tibor1W Actual/365 (Fixed)", 1 * Weeks},
211 {"JPY-TIBOR-1M", "Tibor1M Actual/365 (Fixed)", 1 * Months},
212 {"JPY-TIBOR-2M", "Tibor2M Actual/365 (Fixed)", 2 * Months},
213 {"JPY-TIBOR-3M", "Tibor3M Actual/365 (Fixed)", 3 * Months},
214 {"JPY-TIBOR-6M", "Tibor6M Actual/365 (Fixed)", 6 * Months},
215 {"JPY-TIBOR-12M", "Tibor1Y Actual/365 (Fixed)", 1 * Years},
216 {"JPY-TIBOR-1Y", "Tibor1Y Actual/365 (Fixed)", 1 * Years},
217
218 {"CAD-LIBOR-1W", "CADLibor1W Actual/365 (Fixed)", 1 * Weeks},
219 {"CAD-LIBOR-1M", "CADLibor1M Actual/365 (Fixed)", 1 * Months},
220 {"CAD-LIBOR-2M", "CADLibor2M Actual/365 (Fixed)", 2 * Months},
221 {"CAD-LIBOR-3M", "CADLibor3M Actual/365 (Fixed)", 3 * Months},
222 {"CAD-LIBOR-6M", "CADLibor6M Actual/365 (Fixed)", 6 * Months},
223 {"CAD-LIBOR-12M", "CADLibor1Y Actual/365 (Fixed)", 1 * Years},
224 {"CAD-LIBOR-1Y", "CADLibor1Y Actual/365 (Fixed)", 1 * Years},
225
226 {"CHF-LIBOR-1W", "CHFLibor1W Actual/360", 1 * Weeks},
227 {"CHF-LIBOR-1M", "CHFLibor1M Actual/360", 1 * Months},
228 {"CHF-LIBOR-2M", "CHFLibor2M Actual/360", 2 * Months},
229 {"CHF-LIBOR-3M", "CHFLibor3M Actual/360", 3 * Months},
230 {"CHF-LIBOR-6M", "CHFLibor6M Actual/360", 6 * Months},
231 {"CHF-LIBOR-12M", "CHFLibor1Y Actual/360", 1 * Years},
232 {"CHF-LIBOR-1Y", "CHFLibor1Y Actual/360", 1 * Years},
233
234 {"SAR-SAIBOR-1W", "SAR-SAIBOR1W Actual/360", 1 * Weeks},
235 {"SAR-SAIBOR-1M", "SAR-SAIBOR1M Actual/360", 1 * Months},
236 {"SAR-SAIBOR-2M", "SAR-SAIBOR2M Actual/360", 2 * Months},
237 {"SAR-SAIBOR-3M", "SAR-SAIBOR3M Actual/360", 3 * Months},
238 {"SAR-SAIBOR-6M", "SAR-SAIBOR6M Actual/360", 6 * Months},
239
240 {"SEK-STIBOR-1W", "SEK-STIBOR1W Actual/360", 1 * Weeks},
241 {"SEK-STIBOR-1M", "SEK-STIBOR1M Actual/360", 1 * Months},
242 {"SEK-STIBOR-2M", "SEK-STIBOR2M Actual/360", 2 * Months},
243 {"SEK-STIBOR-3M", "SEK-STIBOR3M Actual/360", 3 * Months},
244 {"SEK-STIBOR-6M", "SEK-STIBOR6M Actual/360", 6 * Months},
245
246 {"SEK-LIBOR-1W", "SEKLibor1W Actual/360", 1 * Weeks},
247 {"SEK-LIBOR-1M", "SEKLibor1M Actual/360", 1 * Months},
248 {"SEK-LIBOR-2M", "SEKLibor2M Actual/360", 2 * Months},
249 {"SEK-LIBOR-3M", "SEKLibor3M Actual/360", 3 * Months},
250 {"SEK-LIBOR-6M", "SEKLibor6M Actual/360", 6 * Months},
251 {"SEK-LIBOR-12M", "SEKLibor1Y Actual/360", 1 * Years},
252 {"SEK-LIBOR-1Y", "SEKLibor1Y Actual/360", 1 * Years},
253
254 {"NOK-NIBOR-1W", "NOK-NIBOR1W Actual/360", 1 * Weeks},
255 {"NOK-NIBOR-1M", "NOK-NIBOR1M Actual/360", 1 * Months},
256 {"NOK-NIBOR-2M", "NOK-NIBOR2M Actual/360", 2 * Months},
257 {"NOK-NIBOR-3M", "NOK-NIBOR3M Actual/360", 3 * Months},
258 {"NOK-NIBOR-6M", "NOK-NIBOR6M Actual/360", 6 * Months},
259 {"NOK-NIBOR-9M", "NOK-NIBOR9M Actual/360", 9 * Months},
260 {"NOK-NIBOR-12M", "NOK-NIBOR1Y Actual/360", 1 * Years},
261 {"NOK-NIBOR-1Y", "NOK-NIBOR1Y Actual/360", 1 * Years},
262
263 {"HKD-HIBOR-1W", "HKD-HIBOR1W Actual/365 (Fixed)", 1 * Weeks},
264 {"HKD-HIBOR-2W", "HKD-HIBOR2W Actual/365 (Fixed)", 2 * Weeks},
265 {"HKD-HIBOR-1M", "HKD-HIBOR1M Actual/365 (Fixed)", 1 * Months},
266 {"HKD-HIBOR-2M", "HKD-HIBOR2M Actual/365 (Fixed)", 2 * Months},
267 {"HKD-HIBOR-3M", "HKD-HIBOR3M Actual/365 (Fixed)", 3 * Months},
268 {"HKD-HIBOR-6M", "HKD-HIBOR6M Actual/365 (Fixed)", 6 * Months},
269 {"HKD-HIBOR-12M", "HKD-HIBOR1Y Actual/365 (Fixed)", 1 * Years},
270 {"HKD-HIBOR-1Y", "HKD-HIBOR1Y Actual/365 (Fixed)", 1 * Years},
271
272 {"SGD-SIBOR-1M", "SGD-SIBOR1M Actual/365 (Fixed)", 1 * Months},
273 {"SGD-SIBOR-3M", "SGD-SIBOR3M Actual/365 (Fixed)", 3 * Months},
274 {"SGD-SIBOR-6M", "SGD-SIBOR6M Actual/365 (Fixed)", 6 * Months},
275 {"SGD-SIBOR-12M", "SGD-SIBOR1Y Actual/365 (Fixed)", 1 * Years},
276 {"SGD-SIBOR-1Y", "SGD-SIBOR1Y Actual/365 (Fixed)", 1 * Years},
277
278 {"SGD-SOR-1M", "SGD-SOR1M Actual/365 (Fixed)", 1 * Months},
279 {"SGD-SOR-3M", "SGD-SOR3M Actual/365 (Fixed)", 3 * Months},
280 {"SGD-SOR-6M", "SGD-SOR6M Actual/365 (Fixed)", 6 * Months},
281 {"SGD-SOR-12M", "SGD-SOR1Y Actual/365 (Fixed)", 1 * Years},
282 {"SGD-SOR-1Y", "SGD-SOR1Y Actual/365 (Fixed)", 1 * Years},
283
284 {"DKK-LIBOR-1W", "DKKLibor1W Actual/360", 1 * Weeks},
285 {"DKK-LIBOR-1M", "DKKLibor1M Actual/360", 1 * Months},
286 {"DKK-LIBOR-2M", "DKKLibor2M Actual/360", 2 * Months},
287 {"DKK-LIBOR-3M", "DKKLibor3M Actual/360", 3 * Months},
288 {"DKK-LIBOR-6M", "DKKLibor6M Actual/360", 6 * Months},
289 {"DKK-LIBOR-12M", "DKKLibor1Y Actual/360", 1 * Years},
290 {"DKK-LIBOR-1Y", "DKKLibor1Y Actual/360", 1 * Years},
291
292 {"DKK-CIBOR-1W", "DKK-CIBOR1W Actual/360", 1 * Weeks},
293 {"DKK-CIBOR-1M", "DKK-CIBOR1M Actual/360", 1 * Months},
294 {"DKK-CIBOR-2M", "DKK-CIBOR2M Actual/360", 2 * Months},
295 {"DKK-CIBOR-3M", "DKK-CIBOR3M Actual/360", 3 * Months},
296 {"DKK-CIBOR-6M", "DKK-CIBOR6M Actual/360", 6 * Months},
297 {"DKK-CIBOR-12M", "DKK-CIBOR1Y Actual/360", 1 * Years},
298 {"DKK-CIBOR-1Y", "DKK-CIBOR1Y Actual/360", 1 * Years},
299
300 {"HUF-BUBOR-6M", "HUF-BUBOR6M Actual/360", 6 * Months},
301 {"IDR-IDRFIX-6M", "IDR-IDRFIX6M Actual/360", 6 * Months},
302 {"INR-MIFOR-6M", "INR-MIFOR6M Actual/365 (Fixed)", 6 * Months},
303 {"MXN-TIIE-6M", "MXN-TIIE6M Actual/360", 6 * Months},
304 {"MXN-TIIE-28D", "MXN-TIIE4W Actual/360", 4 * Weeks},
305 {"MXN-TIIE-4W", "MXN-TIIE4W Actual/360", 4 * Weeks},
306 {"MXN-TIIE-91D", "MXN-TIIE3M Actual/360", 3 * Months},
307 {"MXN-TIIE-3M", "MXN-TIIE3M Actual/360", 3 * Months},
308 {"PLN-WIBOR-6M", "WIBOR6M Actual/365 (Fixed)", 6 * Months},
309 {"SKK-BRIBOR-6M", "SKK-BRIBOR6M Actual/360", 6 * Months},
310 {"THB-THBFIX-6M", "THBFIX6M Actual/365 (Fixed)", 6 * Months},
311
312 {"NZD-BKBM-1M", "NZD-BKBM1M Actual/Actual (ISDA)", 1 * Months},
313 {"NZD-BKBM-2M", "NZD-BKBM2M Actual/Actual (ISDA)", 2 * Months},
314 {"NZD-BKBM-3M", "NZD-BKBM3M Actual/Actual (ISDA)", 3 * Months},
315 {"NZD-BKBM-4M", "NZD-BKBM4M Actual/Actual (ISDA)", 4 * Months},
316 {"NZD-BKBM-5M", "NZD-BKBM5M Actual/Actual (ISDA)", 5 * Months},
317 {"NZD-BKBM-6M", "NZD-BKBM6M Actual/Actual (ISDA)", 6 * Months},
318
319 {"KRW-KORIBOR-1M", "KRW-KORIBOR1M Actual/365 (Fixed)", 1 * Months},
320 {"KRW-KORIBOR-2M", "KRW-KORIBOR2M Actual/365 (Fixed)", 2 * Months},
321 {"KRW-KORIBOR-3M", "KRW-KORIBOR3M Actual/365 (Fixed)", 3 * Months},
322 {"KRW-KORIBOR-4M", "KRW-KORIBOR4M Actual/365 (Fixed)", 4 * Months},
323 {"KRW-KORIBOR-5M", "KRW-KORIBOR5M Actual/365 (Fixed)", 5 * Months},
324 {"KRW-KORIBOR-6M", "KRW-KORIBOR6M Actual/365 (Fixed)", 6 * Months},
325 {"KRW-CD-91D", "KRW-CD3M Actual/365 (Fixed)", 3 * Months},
326 {"KRW-CD-3M", "KRW-CD3M Actual/365 (Fixed)", 3 * Months},
327
328 {"TWD-TAIBOR-1M", "TWD-TAIBOR1M Actual/365 (Fixed)", 1 * Months},
329 {"TWD-TAIBOR-2M", "TWD-TAIBOR2M Actual/365 (Fixed)", 2 * Months},
330 {"TWD-TAIBOR-3M", "TWD-TAIBOR3M Actual/365 (Fixed)", 3 * Months},
331 {"TWD-TAIBOR-4M", "TWD-TAIBOR4M Actual/365 (Fixed)", 4 * Months},
332 {"TWD-TAIBOR-5M", "TWD-TAIBOR5M Actual/365 (Fixed)", 5 * Months},
333 {"TWD-TAIBOR-6M", "TWD-TAIBOR6M Actual/365 (Fixed)", 6 * Months},
334
335 {"TRY-TRLIBOR-1M", "TRLibor1M Actual/360", 1 * Months},
336 {"TRY-TRLIBOR-2M", "TRLibor2M Actual/360", 2 * Months},
337 {"TRY-TRLIBOR-3M", "TRLibor3M Actual/360", 3 * Months},
338 {"TRY-TRLIBOR-4M", "TRLibor4M Actual/360", 4 * Months},
339 {"TRY-TRLIBOR-5M", "TRLibor5M Actual/360", 5 * Months},
340 {"TRY-TRLIBOR-6M", "TRLibor6M Actual/360", 6 * Months},
341
342 {"MYR-KLIBOR-1M", "MYR-KLIBOR1M Actual/365 (Fixed)", 1 * Months},
343 {"MYR-KLIBOR-2M", "MYR-KLIBOR2M Actual/365 (Fixed)", 2 * Months},
344 {"MYR-KLIBOR-3M", "MYR-KLIBOR3M Actual/365 (Fixed)", 3 * Months},
345 {"MYR-KLIBOR-4M", "MYR-KLIBOR4M Actual/365 (Fixed)", 4 * Months},
346 {"MYR-KLIBOR-5M", "MYR-KLIBOR5M Actual/365 (Fixed)", 5 * Months},
347 {"MYR-KLIBOR-6M", "MYR-KLIBOR6M Actual/365 (Fixed)", 6 * Months}};
348
349
350static struct test_data swap_index_data[] = {
351 {"EUR-CMS-2Y", "EURLiborSwapIsdaFix2Y 30/360 (Bond Basis)", 2 * Years},
352 {"EUR-CMS-30Y", "EURLiborSwapIsdaFix30Y 30/360 (Bond Basis)", 30 * Years},
353 {"USD-CMS-2Y", "USDLiborSwapIsdaFix2Y 30/360 (Bond Basis)", 2 * Years},
354 {"USD-CMS-30Y", "USDLiborSwapIsdaFix30Y 30/360 (Bond Basis)", 30 * Years},
355 {"GBP-CMS-2Y", "GBPLiborSwapIsdaFix2Y Actual/365 (Fixed)", 2 * Years},
356 {"GBP-CMS-30Y", "GBPLiborSwapIsdaFix30Y Actual/365 (Fixed)", 30 * Years},
357 {"CHF-CMS-2Y", "CHFLiborSwapIsdaFix2Y 30/360 (Bond Basis)", 2 * Years},
358 {"CHF-CMS-30Y", "CHFLiborSwapIsdaFix30Y 30/360 (Bond Basis)", 30 * Years},
359 {"JPY-CMS-2Y", "JPYLiborSwapIsdaFix2Y Actual/365 (Fixed)", 2 * Years},
360 {"JPY-CMS-30Y", "JPYLiborSwapIsdaFix30Y Actual/365 (Fixed)", 30 * Years},
361};
362
363//name_ = region_.name() + " " + familyName_;
364static struct test_data_inf inflation_index_data[] = {
365 {"AUCPI", "Australia CPI", Quarterly},
366 {"BEHICP", "Belgium HICP", Monthly},
367 {"EUHICP", "EU HICP", Monthly},
368 {"EUHICPXT", "EU HICPXT", Monthly},
369 {"FRHICP", "France HICP", Monthly},
370 {"FRCPI", "France CPI", Monthly},
371 {"UKRPI", "UK RPI", Monthly},
372 {"USCPI", "USA CPI", Monthly},
373 {"ZACPI", "South Africa CPI", Monthly},
374 {"SECPI", "Sweden CPI", Monthly},
375 {"DKCPI", "Denmark CPI", Monthly},
376 {"CACPI", "Canada CPI", Monthly},
377 {"ESCPI", "Spain CPI", Monthly},
378};
379
380} // namespace
381
382BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
383
384BOOST_AUTO_TEST_SUITE(IndexTests)
385
386BOOST_AUTO_TEST_CASE(testIborIndexParsing) {
387
388 BOOST_TEST_MESSAGE("Testing Ibor Index name parsing...");
389
390 Size len = sizeof(index_data) / sizeof(index_data[0]);
391 for (Size i = 0; i < len; ++i) {
392 string str(ore::data::internalIndexName(index_data[i].str));
393 string index_name(index_data[i].index_name);
394 Period tenor(index_data[i].tenor);
395
396 QuantLib::ext::shared_ptr<IborIndex> ibor;
397 try {
398 ibor = ore::data::parseIborIndex(str);
399 } catch (std::exception& e) {
400 BOOST_FAIL("Ibor Parser failed to parse \"" << str << "\" [exception:" << e.what() << "]");
401 } catch (...) {
402 BOOST_FAIL("Ibor Parser failed to parse \"" << str << "\" [unhandled]");
403 }
404 if (ibor) {
405 BOOST_CHECK_EQUAL(ibor->name(), index_name);
406 BOOST_CHECK_EQUAL(ibor->tenor(), tenor);
407
408 BOOST_TEST_MESSAGE("Parsed \"" << str << "\" and got " << ibor->name());
409 } else
410 BOOST_FAIL("Ibor Parser(" << str << ") returned null pointer");
411 }
412}
413
414BOOST_AUTO_TEST_CASE(testIborIndexParsingFails) {
415
416 BOOST_TEST_MESSAGE("Testing Ibor Index parsing fails...");
417
418 // Test invalid strings
419 BOOST_CHECK_THROW(ore::data::parseIborIndex("EUR-EONIA-1M"), QuantLib::Error);
420 BOOST_CHECK_THROW(ore::data::parseIborIndex("EUR-FALSE-6M"), QuantLib::Error);
421 BOOST_CHECK_THROW(ore::data::parseIborIndex("It's a trap!"), QuantLib::Error);
422}
423
424BOOST_AUTO_TEST_CASE(testSwapIndexParsing) {
425
426 BOOST_TEST_MESSAGE("Testing Swap Index name parsing...");
427
428 Handle<YieldTermStructure> h; // dummy
429
430 Size len = sizeof(swap_index_data) / sizeof(swap_index_data[0]);
431
432 for (Size i = 0; i < len; ++i) {
433 string str(swap_index_data[i].str);
434 string index_name(swap_index_data[i].index_name);
435 Period tenor(swap_index_data[i].tenor);
436 ore::data::InstrumentConventions::instance().setConventions(convs());
437 QuantLib::ext::shared_ptr<SwapIndex> swap;
438 try {
439 swap = ore::data::parseSwapIndex(str, h, h);
440 } catch (std::exception& e) {
441 BOOST_FAIL("Swap Parser failed to parse \"" << str << "\" [exception:" << e.what() << "]");
442 } catch (...) {
443 BOOST_FAIL("Swap Parser failed to parse \"" << str << "\" [unhandled]");
444 }
445 if (swap) {
446 BOOST_CHECK_EQUAL(swap->name(), index_name);
447 BOOST_CHECK_EQUAL(swap->tenor(), tenor);
448
449 BOOST_TEST_MESSAGE("Parsed \"" << str << "\" and got " << swap->name());
450 } else
451 BOOST_FAIL("Swap Parser(" << str << ") returned null pointer");
452 }
453}
454
455BOOST_AUTO_TEST_CASE(testInflationIndexParsing) {
456
457 BOOST_TEST_MESSAGE("Testing Inflation Index name parsing...");
458
459 Size len = sizeof(inflation_index_data) / sizeof(inflation_index_data[0]);
460 for (Size i = 0; i < len; ++i) {
461 string str(inflation_index_data[i].str);
462 string index_name(inflation_index_data[i].index_name);
463 Frequency frequency(inflation_index_data[i].frequency);
464
465 QuantLib::ext::shared_ptr<ZeroInflationIndex> cpi;
466 try {
468 } catch (std::exception& e) {
469 BOOST_FAIL("Inflation Index Parser failed to parse \"" << str << "\" [exception:" << e.what() << "]");
470 } catch (...) {
471 BOOST_FAIL("Inflation Index Parser failed to parse \"" << str << "\" [unhandled]");
472 }
473 if (cpi) {
474 BOOST_CHECK_EQUAL(cpi->name(), index_name);
475 BOOST_CHECK_EQUAL(cpi->frequency(), frequency);
476 // Frequency
477 //Availability lag?
478
479 BOOST_TEST_MESSAGE("Parsed \"" << str << "\" and got " << cpi->name());
480 } else
481 BOOST_FAIL("Inflation Index Parser(" << str << ") returned null pointer");
482 }
483}
484
485BOOST_AUTO_TEST_SUITE_END()
486
487BOOST_AUTO_TEST_SUITE_END()
Repository for currency dependent market conventions.
Container for storing Interest Rate Swap conventions.
Container for storing Swap Index conventions.
Currency and instrument specific conventions/defaults.
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex(const string &s, const Handle< ZeroInflationTermStructure > &h)
Convert std::string to QuantLib::ZeroInflationIndex.
QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex(const string &s, const Handle< YieldTermStructure > &f, const Handle< YieldTermStructure > &d)
Convert std::string to QuantLib::SwapIndex.
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
Convert std::string to QuantLib::IborIndex.
string internalIndexName(const string &indexName)
Map text representations to QuantLib/QuantExt types.
BOOST_AUTO_TEST_CASE(testIborIndexParsing)
Definition: indices.cpp:386
Serializable Credit Default Swap.
Definition: namespaces.docs:23