25#include <ql/time/calendars/all.hpp>
50#include <boost/algorithm/string.hpp>
61 boost::shared_lock<boost::shared_mutex> lock(
mutex_);
67 std::vector<std::string> calendarNames;
68 split(calendarNames,
name, boost::is_any_of(
",()"));
71 QL_REQUIRE(calendarNames.size() > 1,
"Cannot convert \"" <<
name <<
"\" to calendar");
73 calendarNames.erase(std::remove(calendarNames.begin(), calendarNames.end(),
"JoinHolidays"),
75 calendarNames.erase(std::remove(calendarNames.begin(), calendarNames.end(),
"JoinBusinessDays"),
77 calendarNames.erase(std::remove(calendarNames.begin(), calendarNames.end(),
""), calendarNames.end());
79 std::vector<QuantLib::Calendar> calendars;
80 for (Size i = 0; i < calendarNames.size(); i++) {
81 boost::trim(calendarNames[i]);
84 }
catch (std::exception& e) {
85 QL_FAIL(
"Cannot convert \"" <<
name <<
"\" to Calendar [exception:" << e.what() <<
"]");
87 QL_FAIL(
"Cannot convert \"" <<
name <<
"\" to Calendar [unhandled exception]");
90 return QuantLib::JointCalendar(calendars);
96 boost::unique_lock<boost::shared_mutex> lock(
mutex_);
101 return std::move(tmp);
110 boost::unique_lock<boost::shared_mutex> lock(
mutex_);
120 static std::map<std::string, QuantExt::Calendar> ref = {
122 {
"TARGET", TARGET()},
125 {
"CN-IB", China(China::IB)},
126 {
"US-FED", UnitedStates(UnitedStates::FederalReserve)},
127 {
"US-GOV", UnitedStates(UnitedStates::GovernmentBond)},
128 {
"US-NERC", UnitedStates(UnitedStates::NERC)},
129 {
"US-NYSE", UnitedStates(UnitedStates::NYSE)},
130 {
"US-SET", UnitedStates(UnitedStates::Settlement)},
131 {
"US-SOFR", UnitedStates(UnitedStates::SOFR)},
134 {
"Australia", Australia()},
135 {
"Canada", Canada()},
137 {
"Denmark", Denmark()},
141 {
"Norway", Norway()},
143 {
"Sweden", Sweden()},
150 {
"FRA", Germany(Germany::Settlement)},
156 {
"GBLO", UnitedKingdom()},
159 {
"USNY", UnitedStates(UnitedStates::Settlement)},
176 {
"CZ", CzechRepublic()},
181 {
"DE", Germany(Germany::Settlement)},
188 {
"IL", QuantLib::Israel()},
195 {
"NZ", NewZealand()},
203 {
"ZA", SouthAfrica()},
204 {
"KR", SouthKorea(SouthKorea::Settlement)},
211 {
"GB", UnitedKingdom()},
212 {
"US", UnitedStates(UnitedStates::Settlement)},
219 {
"ARG", Argentina()},
220 {
"AUS", Australia()},
229 {
"CZE", CzechRepublic()},
234 {
"DEU", Germany(Germany::Settlement)},
241 {
"IDN", Indonesia()},
242 {
"ISR", QuantLib::Israel()},
249 {
"NZL", NewZealand()},
255 {
"SAU", SaudiArabia()},
256 {
"SGP", Singapore()},
257 {
"ZAF", SouthAfrica()},
258 {
"KOR", SouthKorea(SouthKorea::Settlement)},
265 {
"GBR", UnitedKingdom()},
266 {
"USA", UnitedStates(UnitedStates::Settlement)},
273 {
"ARS", Argentina()},
274 {
"AUD", Australia()},
282 {
"CZK", CzechRepublic()},
288 {
"IDR", Indonesia()},
289 {
"ILS", QuantLib::Israel()},
296 {
"NZD", NewZealand()},
302 {
"SAR", SaudiArabia()},
303 {
"SGD", Singapore()},
304 {
"ZAR", SouthAfrica()},
305 {
"KRW", SouthKorea(SouthKorea::Settlement)},
313 {
"GBP", UnitedKingdom()},
314 {
"USD", UnitedStates(UnitedStates::Settlement)},
320 {
"GBp", UnitedKingdom()},
321 {
"GBX", UnitedKingdom()},
322 {
"ILa", QuantLib::Israel()},
323 {
"ILX", QuantLib::Israel()},
324 {
"ILs", QuantLib::Israel()},
325 {
"ILA", QuantLib::Israel()},
326 {
"ZAc", SouthAfrica()},
327 {
"ZAC", SouthAfrica()},
328 {
"ZAX", SouthAfrica()},
370 {
"XASX", Australia(Australia::ASX)},
371 {
"BVMF", Brazil(Brazil::Exchange)},
372 {
"XTSE", Canada(Canada::TSX)},
373 {
"XSHG", China(China::SSE)},
374 {
"XFRA", Germany(Germany::FrankfurtStockExchange)},
375 {
"XETR", Germany(Germany::Xetra)},
376 {
"ECAG", Germany(Germany::Eurex)},
377 {
"EUWA", Germany(Germany::Euwax)},
378 {
"XJKT", Indonesia(Indonesia::JSX)},
379 {
"XIDX", Indonesia(Indonesia::IDX)},
380 {
"XTAE", QuantLib::Israel(QuantLib::Israel::TASE)},
381 {
"XMIL", Italy(Italy::Exchange)},
383 {
"XKRX", SouthKorea(SouthKorea::KRX)},
385 {
"XLON", UnitedKingdom(UnitedKingdom::Exchange)},
386 {
"XLME", UnitedKingdom(UnitedKingdom::Metals)},
387 {
"XNYS", UnitedStates(UnitedStates::NYSE)},
389 {
"XPAR", QuantLib::France(QuantLib::France::Exchange)},
394 {
"London stock exchange", UnitedKingdom(UnitedKingdom::Exchange)},
395 {
"LNB", UnitedKingdom()},
396 {
"New York stock exchange", UnitedStates(UnitedStates::NYSE)},
397 {
"SOFR fixing calendar", UnitedStates(UnitedStates::SOFR)},
399 {
"NYB", UnitedStates(UnitedStates::Settlement)},
400 {
"SA", SouthAfrica()},
402 {
"SYB", Australia()},
405 {
"UK", UnitedKingdom()},
406 {
"UK settlement", UnitedKingdom()},
407 {
"US settlement", UnitedStates(UnitedStates::Settlement)},
408 {
"US with Libor impact", UnitedStates(UnitedStates::LiborImpact)},
427 {
"WeekendsOnly", WeekendsOnly()},
428 {
"UNMAPPED", WeekendsOnly()},
429 {
"NullCalendar", NullCalendar()},
430 {
"", NullCalendar()}};
435 for (
auto const& c : ref) {
441 boost::unique_lock<boost::shared_mutex> lock(
mutex_);
443 m.second.resetAddedAndRemovedHolidays();
calendar parser singleton class
std::map< std::string, QuantLib::Calendar > calendars_
QuantLib::Calendar addCalendar(const std::string baseName, std::string &newName)
QuantLib::Calendar parseCalendar(const std::string &name) const
boost::shared_mutex mutex_
void resetAddedAndRemovedHolidays()
Serializable Credit Default Swap.