Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
parsers.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016-2021 Quaternion Risk Management Ltd
3 Copyright (C) 2021 Skandinaviska Enskilda Banken AB (publ)
4 All rights reserved.
5
6 This file is part of ORE, a free-software/open-source library
7 for transparent pricing and risk analysis - http://opensourcerisk.org
8
9 ORE is free software: you can redistribute it and/or modify it
10 under the terms of the Modified BSD License. You should have received a
11 copy of the license along with this program.
12 The license is also available online at <http://opensourcerisk.org>
13
14 This program is distributed on the basis that it will form a useful
15 contribution to risk analytics and model standardisation, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file ored/utilities/parsers.cpp
21 \brief
22 \ingroup utilities
23*/
24
25#include <boost/algorithm/string.hpp>
26#include <map>
32#include <ql/errors.hpp>
33#include <ql/indexes/all.hpp>
34#include <ql/time/daycounters/all.hpp>
35#include <ql/utilities/dataparsers.hpp>
38
39#include <boost/lexical_cast.hpp>
40#include <regex>
41
42using namespace QuantLib;
43using namespace QuantExt;
44using namespace std;
45using boost::iequals;
46using boost::algorithm::to_lower_copy;
47
48namespace ore {
49namespace data {
50
51Date parseDate(const string& s) {
52 // TODO: review
53
54 if (s == "")
55 return Date();
56
57 // guess formats from token number and sizes
58 // check permissible lengths
59 QL_REQUIRE((s.size() >= 3 && s.size() <= 6) || s.size() == 8 || s.size() == 10,
60 "invalid date format of \"" << s << "\", date string length 8 or 10 or between 3 and 6 required");
61
62 vector<string> tokens;
63 boost::split(tokens, s, boost::is_any_of("-/.:"));
64
65 if (tokens.size() == 1) {
66 if (s.size() == 8) {
67 // yyyymmdd
68 int y = parseInteger(s.substr(0, 4));
69 int m = parseInteger(s.substr(4, 2));
70 int d = parseInteger(s.substr(6, 2));
71 return Date(d, Month(m), y);
72 } else if (s.size() >= 3 && s.size() <= 6) {
73 // Excel format
74 // Boundaries will be checked by Date constructor
75 // Boundaries are minDate = 367 i.e. Jan 1st, 1901
76 // and maxDate = 109574 i.e. Dec 31st, 2199
77 BigInteger serial = parseInteger(s);
78 return Date(serial);
79 }
80 } else if (tokens.size() == 3) {
81 if (tokens[0].size() == 4) {
82 // yyyy-mm-dd
83 // yyyy/mm/dd
84 // yyyy.mm.dd
85 int y = parseInteger(tokens[0]);
86 int m = parseInteger(tokens[1]);
87 int d = parseInteger(tokens[2]);
88 return Date(d, Month(m), y);
89 } else if (tokens[0].size() == 2) {
90 // dd-mm-yy
91 // dd/mm/yy
92 // dd.mm.yy
93 // dd-mm-yyyy
94 // dd/mm/yyyy
95 // dd.mm.yyyy
96 int d = parseInteger(tokens[0]);
97 int m = parseInteger(tokens[1]);
98 int y = parseInteger(tokens[2]);
99 if (y < 100) {
100 if (y > 80)
101 y += 1900;
102 else
103 y += 2000;
104 }
105 return Date(d, Month(m), y);
106 }
107 }
108
109 QL_FAIL("Cannot convert \"" << s << "\" to Date.");
110}
111
112Real parseReal(const string& s) {
113 try {
114 return std::stod(s);
115 } catch (const std::exception& ex) {
116 QL_FAIL("Failed to parseReal(\"" << s << "\") " << ex.what());
117 }
118}
119
120Real parseRealOrNull(const string& s) {
121 if(s.empty())
122 return Null<Real>();
123 return parseReal(s);
124}
125
126bool tryParseReal(const string& s, QuantLib::Real& result) {
127 try {
128 result = std::stod(s);
129 } catch (...) {
130 result = Null<Real>();
131 return false;
132 }
133 return true;
134}
135
136Integer parseInteger(const string& s) {
137 try {
138 return boost::lexical_cast<Integer>(s.c_str());
139 } catch (std::exception& ex) {
140 QL_FAIL("Failed to parseInteger(\"" << s << "\") " << ex.what());
141 }
142}
143
144bool parseBool(const string& s) {
145 static map<string, bool> b = {{"Y", true}, {"YES", true}, {"TRUE", true}, {"True", true},
146 {"true", true}, {"1", true}, {"N", false}, {"NO", false},
147 {"FALSE", false}, {"False", false}, {"false", false}, {"0", false}};
148
149 auto it = b.find(s);
150 if (it != b.end()) {
151 return it->second;
152 } else {
153 QL_FAIL("Cannot convert \"" << s << "\" to bool");
154 }
155}
156
157Calendar parseCalendar(const string& s) { return CalendarParser::instance().parseCalendar(s); }
158
159bool isOnePeriod(const string& s) {
160 if (s.empty())
161 return false;
162 char c = std::toupper(s.back());
163 if (!(c == 'D' || c == 'W' || c == 'M' || c == 'Y'))
164 return false;
165 for (auto c = s.cbegin(); c != std::next(s.end(), -1); std::advance(c, 1))
166 if (*c < '0' || *c > '9')
167 return false;
168 return true;
169}
170
171Period parsePeriod(const string& s) { return PeriodParser::parse(s); }
172
173BusinessDayConvention parseBusinessDayConvention(const string& s) {
174 static map<string, BusinessDayConvention> m = {{"F", Following},
175 {"Following", Following},
176 {"FOLLOWING", Following},
177 {"MF", ModifiedFollowing},
178 {"ModifiedFollowing", ModifiedFollowing},
179 {"Modified Following", ModifiedFollowing},
180 {"MODIFIEDF", ModifiedFollowing},
181 {"MODFOLLOWING", ModifiedFollowing},
182 {"P", Preceding},
183 {"Preceding", Preceding},
184 {"PRECEDING", Preceding},
185 {"MP", ModifiedPreceding},
186 {"ModifiedPreceding", ModifiedPreceding},
187 {"Modified Preceding", ModifiedPreceding},
188 {"MODIFIEDP", ModifiedPreceding},
189 {"U", Unadjusted},
190 {"Unadjusted", Unadjusted},
191 {"INDIFF", Unadjusted},
192 {"HalfMonthModifiedFollowing", HalfMonthModifiedFollowing},
193 {"HMMF", HalfMonthModifiedFollowing},
194 {"Half Month Modified Following", HalfMonthModifiedFollowing},
195 {"HALFMONTHMF", HalfMonthModifiedFollowing},
196 {"HalfMonthMF", HalfMonthModifiedFollowing},
197 {"NEAREST", Nearest},
198 {"NONE", Unadjusted},
199 {"NotApplicable", Unadjusted}};
200
201 auto it = m.find(s);
202 if (it != m.end()) {
203 return it->second;
204 } else {
205 QL_FAIL("Cannot convert \"" << s << "\" to BusinessDayConvention");
206 }
207}
208
209DayCounter parseDayCounter(const string& s) {
210 static map<string, DayCounter> m = {{"A360", Actual360()},
211 {"Actual/360", Actual360()},
212 {"ACT/360", Actual360()},
213 {"Act/360", Actual360()},
214 {"A360 (Incl Last)", Actual360(true)},
215 {"Actual/360 (Incl Last)", Actual360(true)},
216 {"ACT/360 (Incl Last)", Actual360(true)},
217 {"Act/360 (Incl Last)", Actual360(true)},
218 {"A365", Actual365Fixed()},
219 {"A365F", Actual365Fixed()},
220 {"Actual/365 (Fixed)", Actual365Fixed()},
221 {"Actual/365 (fixed)", Actual365Fixed()},
222 {"ACT/365.FIXED", Actual365Fixed()},
223 {"ACT/365", Actual365Fixed()},
224 {"ACT/365L", Actual365Fixed()},
225 {"Act/365", Actual365Fixed()},
226 {"Act/365L", Actual365Fixed()},
227 {"Act/365 (Canadian Bond)", Actual365Fixed(Actual365Fixed::Canadian)},
228 {"T360", Thirty360(Thirty360::USA)},
229 {"30/360", Thirty360(Thirty360::USA)},
230 {"30/360 US", Thirty360(Thirty360::USA)},
231 {"30/360 (US)", Thirty360(Thirty360::USA)},
232 {"30U/360", Thirty360(Thirty360::USA)},
233 {"30US/360", Thirty360(Thirty360::USA)},
234 {"30/360 (Bond Basis)", Thirty360(Thirty360::BondBasis)},
235 {"ACT/nACT", Thirty360(Thirty360::USA)},
236 {"30E/360 (Eurobond Basis)", Thirty360(Thirty360::European)},
237 {"30/360 AIBD (Euro)", Thirty360(Thirty360::European)},
238 {"30E/360.ICMA", Thirty360(Thirty360::European)},
239 {"30E/360 ICMA", Thirty360(Thirty360::European)},
240 {"30E/360", Thirty360(Thirty360::European)},
241 {"30E/360E", Thirty360(Thirty360::German)},
242 {"30E/360.ISDA", Thirty360(Thirty360::German)},
243 {"30E/360 ISDA", Thirty360(Thirty360::German)},
244 {"30/360 German", Thirty360(Thirty360::German)},
245 {"30/360 (German)", Thirty360(Thirty360::German)},
246 {"30/360 Italian", Thirty360(Thirty360::Italian)},
247 {"30/360 (Italian)", Thirty360(Thirty360::Italian)},
248 {"ActActISDA", ActualActual(ActualActual::ISDA)},
249 {"ACT/ACT.ISDA", ActualActual(ActualActual::ISDA)},
250 {"Actual/Actual (ISDA)", ActualActual(ActualActual::ISDA)},
251 {"ActualActual (ISDA)", ActualActual(ActualActual::ISDA)},
252 {"ACT/ACT", ActualActual(ActualActual::ISDA)},
253 {"Act/Act", ActualActual(ActualActual::ISDA)},
254 {"ACT29", ActualActual(ActualActual::AFB)},
255 {"ACT", ActualActual(ActualActual::ISDA)},
256 {"ActActISMA", ActualActual(ActualActual::ISMA)},
257 {"Actual/Actual (ISMA)", ActualActual(ActualActual::ISMA)},
258 {"ActualActual (ISMA)", ActualActual(ActualActual::ISMA)},
259 {"ACT/ACT.ISMA", ActualActual(ActualActual::ISMA)},
260 {"ActActICMA", ActualActual(ActualActual::ISMA)},
261 {"Actual/Actual (ICMA)", ActualActual(ActualActual::ISMA)},
262 {"ActualActual (ICMA)", ActualActual(ActualActual::ISMA)},
263 {"ACT/ACT.ICMA", ActualActual(ActualActual::ISMA)},
264 {"ActActAFB", ActualActual(ActualActual::AFB)},
265 {"ACT/ACT.AFB", ActualActual(ActualActual::AFB)},
266 {"Actual/Actual (AFB)", ActualActual(ActualActual::AFB)},
267 {"1/1", OneDayCounter()},
268 {"BUS/252", Business252()},
269 {"Business/252", Business252()},
270 {"Actual/365 (No Leap)", Actual365Fixed(Actual365Fixed::NoLeap)},
271 {"Act/365 (NL)", Actual365Fixed(Actual365Fixed::NoLeap)},
272 {"NL/365", Actual365Fixed(Actual365Fixed::NoLeap)},
273 {"Actual/365 (JGB)", Actual365Fixed(Actual365Fixed::NoLeap)},
274 {"Simple", SimpleDayCounter()},
275 {"Year", YearCounter()},
276 {"A364", QuantLib::Actual364()},
277 {"Actual/364", Actual364()},
278 {"Act/364", Actual364()},
279 {"ACT/364", Actual364()}};
280
281 auto it = m.find(s);
282 if (it != m.end()) {
283 return it->second;
284
285 } else {
286 QL_FAIL("DayCounter \"" << s << "\" not recognized");
287 }
288}
289
290Currency parseCurrency(const string& s) { return CurrencyParser::instance().parseCurrency(s); }
291
292QuantExt::ConfigurableCurrency::Type parseCurrencyType(const string& s) {
293 static map<string, QuantExt::ConfigurableCurrency::Type> m = {
294 {"Major", QuantExt::ConfigurableCurrency::Type::Major}, {"Fiat Currency", QuantExt::ConfigurableCurrency::Type::Major},
295 {"Fiat", QuantExt::ConfigurableCurrency::Type::Major}, {"Metal", QuantExt::ConfigurableCurrency::Type::Metal},
296 {"Precious Metal", QuantExt::ConfigurableCurrency::Type::Metal}, {"Crypto", QuantExt::ConfigurableCurrency::Type::Crypto},
297 {"Cryptocurrency", QuantExt::ConfigurableCurrency::Type::Crypto}};
298
299 auto it = m.find(s);
300 if (it != m.end()) {
301 return it->second;
302 } else {
303 QL_FAIL("Currency type \"" << s << "\" not recognised");
304 }
305}
306
307
308Currency parseMinorCurrency(const string& s) { return CurrencyParser::instance().parseMinorCurrency(s); }
309
310Currency parseCurrencyWithMinors(const string& s) { return CurrencyParser::instance().parseCurrencyWithMinors(s); }
311
312pair<Currency, Currency> parseCurrencyPair(const string& s, const string& delimiters) {
313 return CurrencyParser::instance().parseCurrencyPair(s, delimiters);
314}
315
316bool checkCurrency(const string& code) { return CurrencyParser::instance().isValidCurrency(code); }
317
318bool isPseudoCurrency(const string& code) { return CurrencyParser::instance().isPseudoCurrency(code); }
319
320bool isPreciousMetal(const string& code) { return CurrencyParser::instance().isPreciousMetal(code); }
321
322bool isCryptoCurrency(const string& code) { return CurrencyParser::instance().isCryptoCurrency(code); }
323
324QuantLib::Real convertMinorToMajorCurrency(const std::string& s, QuantLib::Real value) {
325 return CurrencyParser::instance().convertMinorToMajorCurrency(s, value);
326}
327
328DateGeneration::Rule parseDateGenerationRule(const string& s) {
329 static map<string, DateGeneration::Rule> m = {{"Backward", DateGeneration::Backward},
330 {"Forward", DateGeneration::Forward},
331 {"Zero", DateGeneration::Zero},
332 {"ThirdWednesday", DateGeneration::ThirdWednesday},
333 {"Twentieth", DateGeneration::Twentieth},
334 {"TwentiethIMM", DateGeneration::TwentiethIMM},
335 {"OldCDS", DateGeneration::OldCDS},
336 {"CDS2015", DateGeneration::CDS2015},
337 {"CDS", DateGeneration::CDS},
338 {"LastWednesday", DateGeneration::LastWednesday}};
339
340 auto it = m.find(s);
341 if (it != m.end()) {
342 return it->second;
343 } else {
344 QL_FAIL("Date Generation Rule \"" << s << "\" not recognized");
345 }
346}
347
348Frequency parseFrequency(const string& s) {
349 static map<string, Frequency> m = {{"Z", Once},
350 {"Once", Once},
351 {"A", Annual},
352 {"Annual", Annual},
353 {"S", Semiannual},
354 {"Semiannual", Semiannual},
355 {"Q", Quarterly},
356 {"Quarterly", Quarterly},
357 {"B", Bimonthly},
358 {"Bimonthly", Bimonthly},
359 {"M", Monthly},
360 {"Monthly", Monthly},
361 {"L", EveryFourthWeek},
362 {"Lunarmonth", EveryFourthWeek},
363 {"W", Weekly},
364 {"Weekly", Weekly},
365 {"D", Daily},
366 {"Daily", Daily}};
367
368 auto it = m.find(s);
369 if (it != m.end()) {
370 return it->second;
371 } else {
372 QL_FAIL("Frequency \"" << s << "\" not recognized");
373 }
374}
375
376Compounding parseCompounding(const string& s) {
377 static map<string, Compounding> m = {
378 {"Simple", Simple},
379 {"Compounded", Compounded},
380 {"Continuous", Continuous},
381 {"SimpleThenCompounded", SimpleThenCompounded},
382 };
383
384 auto it = m.find(s);
385 if (it != m.end()) {
386 return it->second;
387 } else {
388 QL_FAIL("Compounding \"" << s << "\" not recognized");
389 }
390}
391
392QuantLib::Bond::Price::Type parseBondPriceType(const string& s) {
393 static map<string, QuantLib::Bond::Price::Type> m = {{"Clean", QuantLib::Bond::Price::Type::Clean},
394 {"Dirty", QuantLib::Bond::Price::Type::Dirty}};
395
396 auto it = m.find(s);
397 if (it != m.end()) {
398 return it->second;
399 } else {
400 QL_FAIL("BondPriceType \"" << s << "\" not recognized");
401 }
402}
403
404Position::Type parsePositionType(const std::string& s) {
405 static map<string, Position::Type> m = {
406 {"Long", Position::Long},
407 {"Short", Position::Short},
408 {"L", Position::Long},
409 {"S", Position::Short},
410 };
411
412 auto it = m.find(s);
413 if (it != m.end()) {
414 return it->second;
415 } else {
416 QL_FAIL("Position type \"" << s << "\" not recognized");
417 }
418}
419
420Protection::Side parseProtectionSide(const std::string& s) {
421 static map<string, Protection::Side> m = {{"Buyer", Protection::Buyer},
422 {"Seller", Protection::Seller},
423 {"B", Protection::Buyer},
424 {"S", Protection::Seller}};
425
426 auto it = m.find(s);
427 if (it != m.end()) {
428 return it->second;
429 } else {
430 QL_FAIL("Protection side \"" << s << "\" not recognized");
431 }
432}
433
434Settlement::Type parseSettlementType(const std::string& s) {
435 static map<string, Settlement::Type> m = {
436 {"Cash", Settlement::Cash},
437 {"Physical", Settlement::Physical},
438 {"C", Settlement::Cash},
439 {"P", Settlement::Physical},
440 };
441
442 auto it = m.find(s);
443 if (it != m.end()) {
444 return it->second;
445 } else {
446 QL_FAIL("Settlement type \"" << s << "\" not recognized");
447 }
448}
449
450Settlement::Method parseSettlementMethod(const std::string& s) {
451 static map<string, Settlement::Method> m = {
452 {"PhysicalOTC", Settlement::PhysicalOTC},
453 {"PhysicalCleared", Settlement::PhysicalCleared},
454 {"CollateralizedCashPrice", Settlement::CollateralizedCashPrice},
455 {"ParYieldCurve", Settlement::ParYieldCurve},
456 };
457
458 auto it = m.find(s);
459 if (it != m.end()) {
460 return it->second;
461 } else {
462 QL_FAIL("Settlement method \"" << s << "\" not recognized");
463 }
464}
465
466Exercise::Type parseExerciseType(const std::string& s) {
467 static map<string, Exercise::Type> m = {
468 {"European", Exercise::European},
469 {"Bermudan", Exercise::Bermudan},
470 {"American", Exercise::American},
471 };
472
473 auto it = m.find(s);
474 if (it != m.end()) {
475 return it->second;
476 } else {
477 QL_FAIL("Exercise type \"" << s << "\" not recognized");
478 }
479}
480
481Option::Type parseOptionType(const std::string& s) {
482 static map<string, Option::Type> m = {{"Put", Option::Put}, {"Call", Option::Call}};
483
484 QL_REQUIRE(!s.empty(), "Option type not given.");
485 auto it = m.find(s);
486 if (it != m.end()) {
487 return it->second;
488 } else {
489 QL_FAIL("Option type \"" << s << "\" not recognized");
490 }
491}
492
493boost::variant<QuantLib::Date, QuantLib::Period> parseDateOrPeriod(const string& s) {
494 QL_REQUIRE(!s.empty(), "Cannot parse empty string as date or period");
495 string c(1, s.back());
496 bool isPeriod = c.find_first_of("DdWwMmYy") != string::npos;
497 if (isPeriod) {
498 return ore::data::parsePeriod(s);
499 } else {
500 return ore::data::parseDate(s);
501 }
502}
503
504namespace {
505struct legacy_date_or_period_visitor : public boost::static_visitor<> {
506 legacy_date_or_period_visitor(Date& res_d, Period& res_p, bool& res_is_date)
508 void operator()(const QuantLib::Date& d) const {
509 res_d = d;
510 res_is_date = true;
511 }
512 void operator()(const QuantLib::Period& p) const {
513 res_p = p;
514 res_is_date = false;
515 }
516 Date& res_d;
517 Period& res_p;
519};
520} // namespace
521
522void parseDateOrPeriod(const string& s, Date& d, Period& p, bool& isDate) {
523 auto r = parseDateOrPeriod(s);
524 boost::apply_visitor(legacy_date_or_period_visitor(d, p, isDate), r);
525}
526
527QuantLib::LsmBasisSystem::PolynomialType parsePolynomType(const std::string& s) {
528 static map<string, LsmBasisSystem::PolynomialType> poly = {
529 {"Monomial", LsmBasisSystem::PolynomialType::Monomial},
530 {"Laguerre", LsmBasisSystem::PolynomialType::Laguerre},
531 {"Hermite", LsmBasisSystem::PolynomialType::Hermite},
532 {"Hyperbolic", LsmBasisSystem::PolynomialType::Hyperbolic},
533 {"Legendre", LsmBasisSystem::PolynomialType::Legendre},
534 {"Chebyshev", LsmBasisSystem::PolynomialType::Chebyshev},
535 {"Chebyshev2nd", LsmBasisSystem::PolynomialType::Chebyshev2nd},
536 };
537
538 auto it = poly.find(s);
539 if (it != poly.end()) {
540 return it->second;
541 } else {
542 QL_FAIL("Polynom type \"" << s << "\" not recognized");
543 }
544}
545
546std::ostream& operator<<(std::ostream& os, QuantLib::LsmBasisSystem::PolynomialType a) {
547 switch (a) {
548 case LsmBasisSystem::PolynomialType::Monomial:
549 return os << "Monomial";
550 case LsmBasisSystem::PolynomialType::Laguerre:
551 return os << "Laguerre";
552 case LsmBasisSystem::PolynomialType::Hermite:
553 return os << "Hermite";
554 case LsmBasisSystem::PolynomialType::Hyperbolic:
555 return os << "Hyperbolic";
556 case LsmBasisSystem::PolynomialType::Legendre:
557 return os << "Legendre";
558 case LsmBasisSystem::PolynomialType::Chebyshev:
559 return os << "Chebychev";
560 case LsmBasisSystem::PolynomialType::Chebyshev2nd:
561 return os << "Chebychev2nd";
562 default:
563 QL_FAIL("unknown LsmBasisSystem::PolynomialType '" << static_cast<int>(a) << "'");
564 }
565}
566
567SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering(const std::string& s) {
568 static map<string, SobolBrownianGenerator::Ordering> m = {{"Factors", SobolBrownianGenerator::Ordering::Factors},
569 {"Steps", SobolBrownianGenerator::Ordering::Steps},
570 {"Diagonal", SobolBrownianGenerator::Ordering::Diagonal}};
571 auto it = m.find(s);
572 if (it != m.end()) {
573 return it->second;
574 } else {
575 QL_FAIL("SobolBrownianGenerator ordering \"" << s << "\" not recognized");
576 }
577}
578
579SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers(const std::string& s) {
580 static map<string, SobolRsg::DirectionIntegers> m = {
581 {"Unit", SobolRsg::DirectionIntegers::Unit},
582 {"Jaeckel", SobolRsg::DirectionIntegers::Jaeckel},
583 {"SobolLevitan", SobolRsg::DirectionIntegers::SobolLevitan},
584 {"SobolLevitanLemieux", SobolRsg::DirectionIntegers::SobolLevitanLemieux},
585 {"JoeKuoD5", SobolRsg::DirectionIntegers::JoeKuoD5},
586 {"JoeKuoD6", SobolRsg::DirectionIntegers::JoeKuoD6},
587 {"JoeKuoD7", SobolRsg::DirectionIntegers::JoeKuoD7},
588 {"Kuo", SobolRsg::DirectionIntegers::Kuo},
589 {"Kuo2", SobolRsg::DirectionIntegers::Kuo2},
590 {"Kuo3", SobolRsg::DirectionIntegers::Kuo3}};
591 auto it = m.find(s);
592 if (it != m.end()) {
593 return it->second;
594 } else {
595 QL_FAIL("SobolRsg direction integers \"" << s << "\" not recognized");
596 }
597}
598
599Weekday parseWeekday(const string& s) {
600
601 static map<string, Weekday> m = {{"Sun", Weekday::Sunday}, {"Mon", Weekday::Monday}, {"Tue", Weekday::Tuesday},
602 {"Wed", Weekday::Wednesday}, {"Thu", Weekday::Thursday}, {"Fri", Weekday::Friday},
603 {"Sat", Weekday::Saturday}};
604
605 auto it = m.find(s);
606 if (it != m.end()) {
607 return it->second;
608 } else {
609 QL_FAIL("The string \"" << s << "\" is not recognized as a Weekday");
610 }
611}
612
613Month parseMonth(const string& s) {
614
615 static map<string, Month> m = {{"Jan", Month::January}, {"Feb", Month::February}, {"Mar", Month::March},
616 {"Apr", Month::April}, {"May", Month::May}, {"Jun", Month::June},
617 {"Jul", Month::July}, {"Aug", Month::August}, {"Sep", Month::September},
618 {"Oct", Month::October}, {"Nov", Month::November}, {"Dec", Month::December}};
619
620 auto it = m.find(s);
621 if (it != m.end()) {
622 return it->second;
623 } else {
624 QL_FAIL("The string \"" << s << "\" is not recognized as a Month");
625 }
626}
627
628PaymentLag parsePaymentLag(const string& s) {
629 Period p;
630 Natural n;
631 if (tryParse<Period>(s, p, parsePeriod))
632 return p;
633 else if (tryParse<Natural>(s, n, parseInteger))
634 return n;
635 else
636 return 0;
637}
638
639std::vector<string> parseListOfValues(string s, const char escape, const char delim, const char quote) {
640 boost::trim(s);
641 std::vector<string> vec;
642 boost::escaped_list_separator<char> sep(escape, delim, quote);
643 boost::tokenizer<boost::escaped_list_separator<char>> tokens(s, sep);
644 for (auto r : tokens) {
645 boost::trim(r);
646 vec.push_back(r);
647 }
648 return vec;
649}
650
652 static map<string, AmortizationType> type = {
653 {"None", AmortizationType::None},
654 {"FixedAmount", AmortizationType::FixedAmount},
655 {"RelativeToInitialNotional", AmortizationType::RelativeToInitialNotional},
656 {"RelativeToPreviousNotional", AmortizationType::RelativeToPreviousNotional},
657 {"Annuity", AmortizationType::Annuity},
658 {"LinearToMaturity", AmortizationType::LinearToMaturity}};
659
660 auto it = type.find(s);
661 if (it != type.end()) {
662 return it->second;
663 } else {
664 QL_FAIL("Amortitazion type \"" << s << "\" not recognized");
665 }
666}
667
668SequenceType parseSequenceType(const std::string& s) {
669 static map<string, SequenceType> seq = {
670 {"MersenneTwister", SequenceType::MersenneTwister},
671 {"MersenneTwisterAntithetic", SequenceType::MersenneTwisterAntithetic},
672 {"Sobol", SequenceType::Sobol},
673 {"SobolBrownianBridge", SequenceType::SobolBrownianBridge},
674 {"Burley2020SobolBrownianBridge", SequenceType::Burley2020SobolBrownianBridge}};
675 auto it = seq.find(s);
676 if (it != seq.end())
677 return it->second;
678 else
679 QL_FAIL("sequence type \"" << s << "\" not recognised");
680}
681
682QuantLib::CPI::InterpolationType parseObservationInterpolation(const std::string& s) {
683 static map<string, CPI::InterpolationType> seq = {
684 {"Flat", CPI::Flat}, {"Linear", CPI::Linear}, {"AsIndex", CPI::AsIndex}};
685 auto it = seq.find(s);
686 if (it != seq.end())
687 return it->second;
688 else
689 QL_FAIL("observation interpolation type \"" << s << "\" not recognised");
690}
691
692FdmSchemeDesc parseFdmSchemeDesc(const std::string& s) {
693 static std::map<std::string, FdmSchemeDesc> m = {{"CrankNicolson", FdmSchemeDesc::CrankNicolson()},
694 {"Hundsdorfer", FdmSchemeDesc::Hundsdorfer()},
695 {"Douglas", FdmSchemeDesc::Douglas()},
696 {"CraigSneyd", FdmSchemeDesc::CraigSneyd()},
697 {"ModifiedCraigSneyd", FdmSchemeDesc::ModifiedCraigSneyd()},
698 {"ImplicitEuler", FdmSchemeDesc::ImplicitEuler()},
699 {"ExplicitEuler", FdmSchemeDesc::ExplicitEuler()},
700 {"MethodOfLines", FdmSchemeDesc::MethodOfLines()},
701 {"TrBDF2", FdmSchemeDesc::TrBDF2()}};
702
703 auto it = m.find(s);
704 if (it != m.end())
705 return it->second;
706 else
707 QL_FAIL("fdm scheme \"" << s << "\" not recognised");
708}
709
710AssetClass parseAssetClass(const std::string& s) {
711 static map<string, AssetClass> assetClasses = {{"EQ", AssetClass::EQ}, {"FX", AssetClass::FX},
712 {"COM", AssetClass::COM}, {"IR", AssetClass::IR},
713 {"INF", AssetClass::INF}, {"CR", AssetClass::CR},
714 {"BOND", AssetClass::BOND}, {"BOND_INDEX", AssetClass::BOND_INDEX}};
715 auto it = assetClasses.find(s);
716 if (it != assetClasses.end()) {
717 return it->second;
718 } else {
719 QL_FAIL("AssetClass \"" << s << "\" not recognized");
720 }
721}
722
723std::ostream& operator<<(std::ostream& os, AssetClass a) {
724 switch (a) {
725 case AssetClass::EQ:
726 return os << "EQ";
727 case AssetClass::FX:
728 return os << "FX";
729 case AssetClass::COM:
730 return os << "COM";
731 case AssetClass::IR:
732 return os << "IR";
733 case AssetClass::INF:
734 return os << "INF";
735 case AssetClass::CR:
736 return os << "CR";
737 case AssetClass::BOND:
738 return os << "BOND";
740 return os << "BOND_INDEX";
741 default:
742 QL_FAIL("Unknown AssetClass");
743 }
744}
745
746DeltaVolQuote::AtmType parseAtmType(const std::string& s) {
747 static map<string, DeltaVolQuote::AtmType> m = {{"AtmNull", DeltaVolQuote::AtmNull},
748 {"AtmSpot", DeltaVolQuote::AtmSpot},
749 {"AtmFwd", DeltaVolQuote::AtmFwd},
750 {"AtmDeltaNeutral", DeltaVolQuote::AtmDeltaNeutral},
751 {"AtmVegaMax", DeltaVolQuote::AtmVegaMax},
752 {"AtmGammaMax", DeltaVolQuote::AtmGammaMax},
753 {"AtmPutCall50", DeltaVolQuote::AtmPutCall50}};
754
755 auto it = m.find(s);
756 if (it != m.end()) {
757 return it->second;
758 } else {
759 QL_FAIL("ATM type \"" << s << "\" not recognized");
760 }
761}
762
763DeltaVolQuote::DeltaType parseDeltaType(const std::string& s) {
764 static map<string, DeltaVolQuote::DeltaType> m = {{"Spot", DeltaVolQuote::Spot},
765 {"Fwd", DeltaVolQuote::Fwd},
766 {"PaSpot", DeltaVolQuote::PaSpot},
767 {"PaFwd", DeltaVolQuote::PaFwd}};
768
769 auto it = m.find(s);
770 if (it != m.end()) {
771 return it->second;
772 } else {
773 QL_FAIL("Delta type \"" << s << "\" not recognized");
774 }
775}
776
777//! Parse Extrapolation from string
779 if (s == "None") {
780 return Extrapolation::None;
781 } else if (s == "UseInterpolator" || s == "Linear") {
783 } else if (s == "Flat") {
784 return Extrapolation::Flat;
785 } else {
786 QL_FAIL("Extrapolation '" << s << "' not recognized");
787 }
788}
789
790//! Write Extrapolation, \p extrap, to stream.
791std::ostream& operator<<(std::ostream& os, Extrapolation extrap) {
792 switch (extrap) {
794 return os << "None";
796 return os << "UseInterpolator";
798 return os << "Flat";
799 default:
800 QL_FAIL("Unknown Extrapolation");
801 }
802}
803
804VolatilityType parseVolatilityQuoteType(const string& s) {
805
806 if (s == "Normal") {
807 return Normal;
808 } else if (s == "ShiftedLognormal") {
809 return ShiftedLognormal;
810 } else {
811 QL_FAIL("Unknown volatility quote type " << s);
812 }
813}
814
815CapFloor::Type parseCapFloorType(const string& s) {
816 if (s == "Cap") {
817 return CapFloor::Cap;
818 } else if (s == "Floor") {
819 return CapFloor::Floor;
820 } else if (s == "Collar") {
821 return CapFloor::Collar;
822 } else {
823 QL_FAIL("Unknown cap floor type " << s);
824 }
825}
826
827YoYInflationCapFloor::Type parseYoYInflationCapFloorType(const string& s) {
828 if (s == "Cap" || s == "YoYInflationCap") {
829 return YoYInflationCapFloor::Cap;
830 } else if (s == "Floor" || s == "YoYInflationFloor") {
831 return YoYInflationCapFloor::Floor;
832 } else if (s == "Collar" || s == "YoYInflationCollar") {
833 return YoYInflationCapFloor::Collar;
834 } else {
835 QL_FAIL("Unknown year on year inflation cap floor type " << s);
836 }
837}
838
840 if (s == "IR") {
841 return QuantExt::CrossAssetModel::AssetType::IR;
842 } else if (s == "FX") {
843 return QuantExt::CrossAssetModel::AssetType::FX;
844 } else if (s == "INF") {
845 return QuantExt::CrossAssetModel::AssetType::INF;
846 } else if (s == "CR") {
847 return QuantExt::CrossAssetModel::AssetType::CR;
848 } else if (s == "EQ") {
849 return QuantExt::CrossAssetModel::AssetType::EQ;
850 } else if (s == "COM") {
851 return QuantExt::CrossAssetModel::AssetType::COM;
852 } else if (s == "CrState") {
853 return QuantExt::CrossAssetModel::AssetType::CrState;
854 } else {
855 QL_FAIL("Unknown cross asset model type " << s);
856 }
857}
858
859pair<string, string> parseBoostAny(const boost::any& anyType, Size precision) {
860 string resultType;
861 std::ostringstream oss;
862
863 if (anyType.type() == typeid(int)) {
864 resultType = "int";
865 int r = boost::any_cast<int>(anyType);
866 oss << std::fixed << std::setprecision(precision) << r;
867 } else if (anyType.type() == typeid(Size)) {
868 resultType = "size";
869 int r = boost::any_cast<Size>(anyType);
870 oss << std::fixed << std::setprecision(precision) << r;
871 } else if (anyType.type() == typeid(double)) {
872 resultType = "double";
873 double r = boost::any_cast<double>(anyType);
874 if (r != Null<Real>())
875 oss << std::fixed << std::setprecision(precision) << r;
876 } else if (anyType.type() == typeid(std::string)) {
877 resultType = "string";
878 std::string r = boost::any_cast<std::string>(anyType);
879 oss << std::fixed << std::setprecision(precision) << r;
880 } else if (anyType.type() == typeid(Date)) {
881 resultType = "date";
882 oss << io::iso_date(boost::any_cast<Date>(anyType));
883 } else if (anyType.type() == typeid(bool)) {
884 resultType = "bool";
885 oss << std::boolalpha << boost::any_cast<bool>(anyType);
886 } else if (anyType.type() == typeid(std::vector<bool>)) {
887 resultType = "vector_bool";
888 std::vector<bool> r = boost::any_cast<std::vector<bool>>(anyType);
889 if (r.size() == 0) {
890 oss << "";
891 } else {
892 oss << std::boolalpha << "\"" << boost::any_cast<bool>(anyType);
893 for (Size i = 1; i < r.size(); i++) {
894 oss << ", " << r[i];
895 }
896 oss << "\"";
897 }
898 } else if (anyType.type() == typeid(std::vector<double>)) {
899 resultType = "vector_double";
900 std::vector<double> r = boost::any_cast<std::vector<double>>(anyType);
901 if (r.size() == 0) {
902 oss << "";
903 } else {
904 oss << std::fixed << std::setprecision(precision) << "\"";
905 if (r[0] != Null<Real>())
906 oss << r[0];
907 for (Size i = 1; i < r.size(); i++) {
908 oss << ", ";
909 if (r[i] != Null<Real>())
910 oss << r[i];
911 }
912 oss << "\"";
913 }
914 } else if (anyType.type() == typeid(std::vector<Date>)) {
915 resultType = "vector_date";
916 std::vector<Date> r = boost::any_cast<std::vector<Date>>(anyType);
917 if (r.size() == 0) {
918 oss << "";
919 } else {
920 oss << std::fixed << std::setprecision(precision) << "\"" << to_string(r[0]);
921 for (Size i = 1; i < r.size(); i++) {
922 oss << ", " << to_string(r[i]);
923 }
924 oss << "\"";
925 }
926 } else if (anyType.type() == typeid(std::vector<std::string>)) {
927 resultType = "vector_string";
928 std::vector<std::string> r = boost::any_cast<std::vector<std::string>>(anyType);
929 if (r.size() == 0) {
930 oss << "";
931 } else {
932 oss << std::fixed << std::setprecision(precision) << "\"" << r[0];
933 for (Size i = 1; i < r.size(); i++) {
934 oss << ", " << r[i];
935 }
936 oss << "\"";
937 }
938 } else if (anyType.type() == typeid(std::vector<CashFlowResults>)) {
939 resultType = "vector_cashflows";
940 std::vector<CashFlowResults> r = boost::any_cast<std::vector<CashFlowResults>>(anyType);
941 if (!r.empty()) {
942 oss << std::fixed << std::setprecision(precision) << "\"" << r[0];
943 for (Size i = 1; i < r.size(); ++i) {
944 oss << ", " << r[i];
945 }
946 oss << "\"";
947 }
948 } else if (anyType.type() == typeid(QuantLib::Matrix)) {
949 resultType = "matrix";
950 QuantLib::Matrix r = boost::any_cast<QuantLib::Matrix>(anyType);
951 std::regex pattern("\n");
952 std::ostringstream tmp;
953 tmp << std::setprecision(precision) << r;
954 oss << std::fixed << std::regex_replace(tmp.str(), pattern, std::string(""));
955 } else if (anyType.type() == typeid(QuantLib::Array)) {
956 resultType = "array";
957 QuantLib::Array r = boost::any_cast<QuantLib::Array>(anyType);
958 oss << std::fixed << std::setprecision(precision) << r;
959 } else if (anyType.type() == typeid(QuantLib::Currency)) {
960 resultType = "currency";
961 QuantLib::Currency r = boost::any_cast<QuantLib::Currency>(anyType);
962 oss << r;
963 } else {
964 ALOG("Unsupported Boost::Any type");
965 resultType = "unsupported_type";
966 }
967 return make_pair(resultType, oss.str());
968}
969
970QuantLib::RateAveraging::Type parseOvernightIndexFutureNettingType(const std::string& s) {
971 if (s == "Averaging") {
972 return QuantLib::RateAveraging::Type::Simple;
973 } else if (s == "Compounding") {
974 return QuantLib::RateAveraging::Type::Compound;
975 } else {
976 QL_FAIL("Overnight Index Future Netting Type '" << s << "' not known, expected 'Averaging' or 'Compounding'");
977 }
978}
979
980std::ostream& operator<<(std::ostream& os, QuantLib::RateAveraging::Type t) {
981 if (t == QuantLib::RateAveraging::Type::Simple)
982 return os << "Averaging";
983 else if (t == QuantLib::RateAveraging::Type::Compound)
984 return os << "Compounding";
985 else {
986 QL_FAIL("Internal error: unknown RateAveraging::Type - check implementation of operator<< "
987 "for this enum");
988 }
989}
990
992 if (s == "IMM")
994 else if (s == "FirstDayOfMonth")
996 else {
997 QL_FAIL("FutureConvention / DateGenerationRule '" << s << "' not known, expect 'IMM' or 'FirstDayOfMonth'");
998 }
999}
1000
1001std::ostream& operator<<(std::ostream& os, FutureConvention::DateGenerationRule t) {
1003 return os << "IMM";
1005 return os << "FirstDayOfMonth";
1006 else {
1007 QL_FAIL("Internal error: unknown FutureConvention::DateGenerationRule - check implementation of operator<< "
1008 "for this enum");
1009 }
1010}
1011
1014 if (s == "None") {
1015 return IPR::None;
1016 } else if (s == "OnPublicationDate") {
1017 return IPR::OnPublicationDate;
1018 } else if (s == "AfterPublicationDate") {
1019 return IPR::AfterPublicationDate;
1020 } else {
1021 QL_FAIL("InflationSwapConvention::PublicationRoll '"
1022 << s << "' not known, expect "
1023 << "'None', 'OnPublicationDate' or 'AfterPublicationDate'");
1024 }
1025}
1026
1027QuantLib::Rounding::Type parseRoundingType(const std::string& s) {
1028 static map<string, QuantLib::Rounding::Type> m = {{"Up", QuantLib::Rounding::Type::Up},
1029 {"Down", QuantLib::Rounding::Type::Down},
1030 {"Closest", QuantLib::Rounding::Type::Closest},
1031 {"Floor", QuantLib::Rounding::Type::Floor},
1032 {"Ceiling", QuantLib::Rounding::Type::Ceiling}};
1033
1034 auto it = m.find(s);
1035 if (it != m.end()) {
1036 return it->second;
1037 } else {
1038 QL_FAIL("Rounding type \"" << s << "\" not recognized");
1039 }
1040}
1041
1042Barrier::Type parseBarrierType(const std::string& s) {
1043 static map<string, Barrier::Type> type = {{"DownAndIn", Barrier::Type::DownIn},
1044 {"UpAndIn", Barrier::Type::UpIn},
1045 {"DownAndOut", Barrier::Type::DownOut},
1046 {"UpAndOut", Barrier::Type::UpOut},
1047 // Maintain old versions for backwards compatibility
1048 {"Down&In", Barrier::Type::DownIn},
1049 {"Up&In", Barrier::Type::UpIn},
1050 {"Down&Out", Barrier::Type::DownOut},
1051 {"Up&Out", Barrier::Type::UpOut}};
1052
1053 auto it = type.find(s);
1054 if (it != type.end()) {
1055 return it->second;
1056 } else {
1057 QL_FAIL("Barrier type \"" << s << "\" not recognized");
1058 }
1059}
1060
1061DoubleBarrier::Type parseDoubleBarrierType(const std::string& s) {
1062 static map<string, DoubleBarrier::Type> type = {
1063 {"KnockIn", DoubleBarrier::Type::KnockIn},
1064 {"KnockOut", DoubleBarrier::Type::KnockOut},
1065 {"KIKO", DoubleBarrier::Type::KIKO},
1066 {"KOKI", DoubleBarrier::Type::KOKI},
1067 };
1068
1069 auto it = type.find(s);
1070 if (it != type.end()) {
1071 return it->second;
1072 } else {
1073 QL_FAIL("DoubleBarrier type \"" << s << "\" not recognized");
1074 }
1075}
1076
1079 if (pr == IPR::None) {
1080 return os << "None";
1081 } else if (pr == IPR::OnPublicationDate) {
1082 return os << "OnPublicationDate";
1083 } else if (pr == IPR::AfterPublicationDate) {
1084 return os << "AfterPublicationDate";
1085 } else {
1086 QL_FAIL("Unknown InflationSwapConvention::PublicationRoll.");
1087 }
1088}
1089
1090std::ostream& operator<<(std::ostream& os, SobolBrownianGenerator::Ordering t) {
1091 static map<SobolBrownianGenerator::Ordering, string> m = {{SobolBrownianGenerator::Ordering::Factors, "Factors"},
1092 {SobolBrownianGenerator::Ordering::Steps, "Steps"},
1093 {SobolBrownianGenerator::Ordering::Diagonal, "Diagonal"}};
1094 auto it = m.find(t);
1095 if (it != m.end()) {
1096 return os << it->second;
1097 } else {
1098 QL_FAIL("Internal error: unknown SobolBrownianGenerator::Ordering - check implementation of operator<< "
1099 "for this enum");
1100 }
1101}
1102
1103std::ostream& operator<<(std::ostream& os, SobolRsg::DirectionIntegers t) {
1104 static map<SobolRsg::DirectionIntegers, string> m = {
1105 {SobolRsg::DirectionIntegers::Unit, "Unit"},
1106 {SobolRsg::DirectionIntegers::Jaeckel, "Jaeckel"},
1107 {SobolRsg::DirectionIntegers::SobolLevitan, "SobolLevitan"},
1108 {SobolRsg::DirectionIntegers::SobolLevitanLemieux, "SobolLevitanLemieux"},
1109 {SobolRsg::DirectionIntegers::JoeKuoD5, "JoeKuoD5"},
1110 {SobolRsg::DirectionIntegers::JoeKuoD6, "JoeKuoD6"},
1111 {SobolRsg::DirectionIntegers::JoeKuoD7, "JoeKuoD7"},
1112 {SobolRsg::DirectionIntegers::Kuo, "Kuo"},
1113 {SobolRsg::DirectionIntegers::Kuo2, "Kuo2"},
1114 {SobolRsg::DirectionIntegers::Kuo3, "Kuo3"}};
1115 auto it = m.find(t);
1116 if (it != m.end()) {
1117 return os << it->second;
1118 } else {
1119 QL_FAIL("Internal error: unknown SobolRsg::DirectionIntegers - check implementation of operator<< "
1120 "for this enum");
1121 }
1122}
1123
1124std::ostream& operator<<(std::ostream& out, QuantExt::CrossAssetModel::Discretization dis) {
1125 switch (dis) {
1126 case QuantExt::CrossAssetModel::Discretization::Exact:
1127 return out << "Exact";
1128 case QuantExt::CrossAssetModel::Discretization::Euler:
1129 return out << "Euler";
1130 default:
1131 return out << "?";
1132 }
1133}
1134
1137 if (s == "PreviousMonth") {
1138 return ADCP::PreviousMonth;
1139 } else if (s == "ExpiryToExpiry") {
1140 return ADCP::ExpiryToExpiry;
1141 } else {
1142 QL_FAIL("AveragingData::CalculationPeriod '" << s << "' not known, expect "
1143 << "'PreviousMonth' or 'ExpiryToExpiry'");
1144 }
1145}
1146
1147ostream& operator<<(ostream& os, ADCP cp) {
1148 if (cp == ADCP::PreviousMonth) {
1149 return os << "PreviousMonth";
1150 } else if (cp == ADCP::ExpiryToExpiry) {
1151 return os << "ExpiryToExpiry";
1152 } else {
1153 QL_FAIL("Unknown AveragingData::CalculationPeriod.");
1154 }
1155}
1156
1159 if (s == "Future") {
1160 return PST::Future;
1161 } else if (s == "AveragingFuture") {
1162 return PST::AveragingFuture;
1163 } else if (s == "AveragingSpot") {
1164 return PST::AveragingSpot;
1165 } else if (s == "AveragingOffPeakPower") {
1166 return PST::AveragingOffPeakPower;
1167 } else if (s == "OffPeakPowerDaily") {
1168 return PST::OffPeakPowerDaily;
1169 } else {
1170 QL_FAIL("PriceSegment::Type '" << s << "' not known, expect "
1171 << "'Future', 'AveragingFuture' or 'AveragingSpot'");
1172 }
1173}
1174
1175ostream& operator<<(ostream& os, PriceSegment::Type pst) {
1176 if (pst == PST::Future) {
1177 return os << "Future";
1178 } else if (pst == PST::AveragingFuture) {
1179 return os << "AveragingFuture";
1180 } else if (pst == PST::AveragingSpot) {
1181 return os << "AveragingSpot";
1182 } else if (pst == PST::AveragingOffPeakPower) {
1183 return os << "AveragingOffPeakPower";
1184 } else if (pst == PST::OffPeakPowerDaily) {
1185 return os << "OffPeakPowerDaily";
1186 } else {
1187 QL_FAIL("Unknown PriceSegment::Type.");
1188 }
1189}
1190
1193 if (iequals(s, "PerCalculationPeriod")) {
1194 return CQF::PerCalculationPeriod;
1195 } else if (iequals(s, "PerCalendarDay")) {
1196 return CQF::PerCalendarDay;
1197 } else if (iequals(s, "PerPricingDay")) {
1198 return CQF::PerPricingDay;
1199 } else if (iequals(s, "PerHour")) {
1200 return CQF::PerHour;
1201 } else if (iequals(s, "PerHourAndCalendarDay")) {
1202 return CQF::PerHourAndCalendarDay;
1203 } else {
1204 QL_FAIL("Could not parse " << s << " to CommodityQuantityFrequency");
1205 }
1206}
1207
1208ostream& operator<<(ostream& os, CommodityQuantityFrequency cqf) {
1209 if (cqf == CQF::PerCalculationPeriod) {
1210 return os << "PerCalculationPeriod";
1211 } else if (cqf == CQF::PerCalendarDay) {
1212 return os << "PerCalendarDay";
1213 } else if (cqf == CQF::PerPricingDay) {
1214 return os << "PerPricingDay";
1215 } else if (cqf == CQF::PerHour) {
1216 return os << "PerHour";
1217 } else if (cqf == CQF::PerHourAndCalendarDay) {
1218 return os << "PerHourAndCalendarDay";
1219 } else {
1220 QL_FAIL("Do not recognise CommodityQuantityFrequency " << static_cast<int>(cqf));
1221 }
1222}
1223
1224ostream& operator<<(ostream& os, Rounding::Type t) {
1225 static map<Rounding::Type, string> m = {{Rounding::Type::Up, "Up"},
1226 {Rounding::Type::Down, "Down"},
1227 {Rounding::Type::Closest, "Closest"},
1228 {Rounding::Type::Floor, "Floor"},
1229 {Rounding::Type::Ceiling, "Ceiling"}};
1230 auto it = m.find(t);
1231 if (it != m.end()) {
1232 return os << it->second;
1233 } else {
1234 QL_FAIL("Internal error: unknown Rounding::Type - check implementation of operator<< "
1235 "for this enum");
1236 }
1237}
1238
1241 using ST = CdsOption::StrikeType;
1242 if (s == "Spread") {
1243 return ST::Spread;
1244 } else if (s == "Price") {
1245 return ST::Price;
1246 } else {
1247 QL_FAIL("CdsOption::StrikeType \"" << s << "\" not recognized");
1248 }
1249}
1250
1251Average::Type parseAverageType(const std::string& s) {
1252 if (s == "Arithmetic") {
1253 return Average::Type::Arithmetic;
1254 } else if (s == "Geometric") {
1255 return Average::Type::Geometric;
1256 } else {
1257 QL_FAIL("Average::Type '" << s << "' not recognized. Should be Arithmetic or Geometric");
1258 }
1259}
1260
1262 if (s == "CurrencyPerUnit")
1263 return QuantExt::BondIndex::PriceQuoteMethod::CurrencyPerUnit;
1264 else if (s == "PercentageOfPar")
1265 return QuantExt::BondIndex::PriceQuoteMethod::PercentageOfPar;
1266 else {
1267 QL_FAIL("PriceQuoteMethod '" << s << "' not recognized. Expected CurrencyPerUnit or PercentageOfPar.");
1268 }
1269}
1270
1271std::ostream& operator<<(std::ostream& os, QuantExt::BondIndex::PriceQuoteMethod p) {
1272 if (p == QuantExt::BondIndex::PriceQuoteMethod::PercentageOfPar)
1273 os << "PercentageOfPar";
1274 else if (p == QuantExt::BondIndex::PriceQuoteMethod::CurrencyPerUnit)
1275 os << "CurrencyPerUnit";
1276 else
1277 os << "Unknown PriceQuoteMethod (" << static_cast<int>(p) << ")";
1278 return os;
1279}
1280
1281std::vector<std::string> getCorrelationTokens(const std::string& name) {
1282 // Look for & first as it avoids collisions with : which can be used in an index name
1283 // if it is not there we fall back on the old behaviour
1284 string delim;
1285 if (name.find('&') != std::string::npos)
1286 delim = "&";
1287 else
1288 delim = "/:,";
1289 vector<string> tokens;
1290 boost::split(tokens, name, boost::is_any_of(delim));
1291 QL_REQUIRE(tokens.size() == 2,
1292 "invalid correlation name '" << name << "', expected Index2:Index1 or Index2/Index1 or Index2&Index1");
1293 return tokens;
1294}
1295
1296string fxDominance(const string& s1, const string& s2) {
1297
1298 // short cut for trivial inputs EUR,EUR => EUREUR
1299
1300 if (s1 == s2)
1301 return s1 + s2;
1302
1303 // This should run even if we don't have s1 or s2 in our table, it should not throw
1304 // It will also work if s1 == s2
1305
1306 static vector<string> dominance = {// Precious Metals (always are before currencies, Metal crosses are not
1307 // common so the ordering of the actual 4 here is just the standard order we see
1308 "XAU", "XAG", "XPT", "XPD",
1309 // The majors (except JPY)
1310 "EUR", "GBP", "AUD", "NZD", "USD", "CAD", "CHF", "ZAR",
1311 // The rest - not really sure about some of these (MXNSEK anyone)
1312 "MYR", "SGD", // not sure of order here
1313 "DKK", "NOK", "SEK", // order here is correct
1314 "HKD", "THB", "TWD", "MXN", // not sure of order here
1315 "CNY", "CNH",
1316
1317 // JPY at the end (of majors)
1318 "JPY",
1319 // JPYIDR and JPYKRW - who knew!
1320 "IDR", "KRW"};
1321
1322 auto p1 = std::find(dominance.begin(), dominance.end(), s1);
1323 auto p2 = std::find(dominance.begin(), dominance.end(), s2);
1324
1325 // if both on the list - we return the first one first
1326 if (p1 != dominance.end() && p2 != dominance.end()) {
1327 if (p1 > p2)
1328 return s2 + s1;
1329 else
1330 return s1 + s2;
1331 }
1332 // if nether on the list - we return s1+s2
1333 if (p1 == dominance.end() && p2 == dominance.end()) {
1334 WLOG("No dominance for either " << s1 << " or " << s2 << " assuming " << s1 + s2);
1335 return s1 + s2;
1336 }
1337
1338 // if one on the list - we return that first (unless it's JPY - in which case it's last)
1339 if (s1 == "JPY")
1340 return s2 + s1;
1341 else if (s2 == "JPY")
1342 return s1 + s2;
1343 else {
1344 if (p1 != dominance.end())
1345 return s1 + s2;
1346 else
1347 return s2 + s1;
1348 }
1349}
1350
1351string normaliseFxIndex(const std::string& indexName) {
1352 auto fx = ore::data::parseFxIndex(indexName);
1353 std::string ccy1 = fx->sourceCurrency().code();
1354 std::string ccy2 = fx->targetCurrency().code();
1355 if (ore::data::fxDominance(ccy1, ccy2) != ccy1 + ccy2)
1356 return ore::data::inverseFxIndex(indexName);
1357 else
1358 return indexName;
1359}
1360
1361MomentType parseMomentType(const std::string& s) {
1362 static map<string, MomentType> momentTypes = {
1363 {"Variance", MomentType::Variance},
1364 {"Volatility", MomentType::Volatility},
1365 };
1366 auto it = momentTypes.find(s);
1367 if (it != momentTypes.end()) {
1368 return it->second;
1369 } else {
1370 QL_FAIL("momentTypes \"" << s << "\" not recognized");
1371 }
1372}
1373
1375 if (s == "Underlying") {
1377 } else if (s == "NotionalWeighted") {
1379 } else if (s == "LossWeighted") {
1381 } else if (s == "DeltaWeighted") {
1383 } else {
1384 QL_FAIL("CreditPortfolioSensitivityDecomposition '"
1385 << s << "' invalid, expected Underlying, NotionalWeighted, LossWeighted, DeltaWeighted");
1386 }
1387}
1388
1389std::ostream& operator<<(std::ostream& os, const CreditPortfolioSensitivityDecomposition d) {
1391 return os << "Underlying";
1393 return os << "NotionalWeighted";
1395 return os << "LossWeighted";
1397 return os << "DeltaWeighted";
1398 } else {
1399 QL_FAIL("Unknonw CreditPortfolioSensitivitiyDecomposition value " << static_cast<std::size_t>(d));
1400 }
1401}
1402
1403QuantLib::Pillar::Choice parsePillarChoice(const std::string& s) {
1404 /* we support
1405 - the string corresponding to the enum label (preferred, first alternative below)
1406 - the string generated by operator<<() in QuantLib */
1407 if (s == "MaturityDate" || s == "MaturityPillarDate")
1408 return QuantLib::Pillar::MaturityDate;
1409 else if (s == "LastRelevantDate" || s == "LastRelevantPillarDate")
1410 return QuantLib::Pillar::LastRelevantDate;
1411 else if (s == "CustomDate" || s == "CustomPillarDate")
1412 return QuantLib::Pillar::CustomDate;
1413 else {
1414 QL_FAIL("PillarChoice '" << s << "' not recognized, expected MaturityDate, LastRelevantDate, CustomDate");
1415 }
1416}
1417
1418QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel(const std::string& s) {
1419 if (s == "Simple")
1420 return McMultiLegBaseEngine::RegressorModel::Simple;
1421 else if (s == "LaggedFX")
1422 return McMultiLegBaseEngine::RegressorModel::LaggedFX;
1423 else {
1424 QL_FAIL("RegressorModel '" << s << "' not recognized, expected Simple, LaggedFX");
1425 }
1426}
1427
1429 static map<string, MporCashFlowMode> m = {{"Unspecified", MporCashFlowMode::Unspecified},
1430 {"NonePay", MporCashFlowMode::NonePay},
1431 {"BothPay", MporCashFlowMode::BothPay},
1432 {"WePay", MporCashFlowMode::WePay},
1433 {"TheyPay", MporCashFlowMode::TheyPay}};
1434 auto it = m.find(s);
1435 if (it != m.end()) {
1436 return it->second;
1437 } else {
1438 QL_FAIL("Mpor cash flow mode \"" << s << "\" not recognized");
1439 }
1440}
1441std::ostream& operator<<(std::ostream& out, MporCashFlowMode t) {
1443 out << "Unspecified";
1444 else if (t == MporCashFlowMode::NonePay)
1445 out << "NonePay";
1446 else if (t == MporCashFlowMode::BothPay)
1447 out << "BothPay";
1448 else if (t == MporCashFlowMode::WePay)
1449 out << "WePay";
1450 else if (t == MporCashFlowMode::TheyPay)
1451 out << "TheyPay";
1452 else
1453 QL_FAIL("Mpor cash flow mode not covered, expected one of 'Unspecified', 'NonePay', 'BothPay', 'WePay', "
1454 "'TheyPay'.");
1455 return out;
1456}
1457
1458SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant(const std::string& s) {
1459 static map<string, SabrParametricVolatility::ModelVariant> m = {
1460 {"Hagan2002Lognormal", SabrParametricVolatility::ModelVariant::Hagan2002Lognormal},
1461 {"Hagan2002Normal", SabrParametricVolatility::ModelVariant::Hagan2002Normal},
1462 {"Hagan2002NormalZeroBeta", SabrParametricVolatility::ModelVariant::Hagan2002NormalZeroBeta},
1463 {"Antonov2015FreeBoundaryNormal", SabrParametricVolatility::ModelVariant::Antonov2015FreeBoundaryNormal},
1464 {"KienitzLawsonSwaynePde", SabrParametricVolatility::ModelVariant::KienitzLawsonSwaynePde},
1465 {"FlochKennedy", SabrParametricVolatility::ModelVariant::FlochKennedy}};
1466 auto it = m.find(s);
1467 if (it != m.end()) {
1468 return it->second;
1469 } else {
1470 QL_FAIL(
1471 "SabrParametricVolatilityModelVariant '"
1472 << s
1473 << "' not recognized, expected one of 'Hagan2002Lognormal', 'Hagan2002Normal', 'Hagan2002NormalZeroBeta', "
1474 "'Antonov2015FreeBoundaryNormal', 'KienitzLawsonSwaynePde', 'FlochKennedy'.");
1475 }
1476}
1477
1478std::ostream& operator<<(std::ostream& out, SabrParametricVolatility::ModelVariant m) {
1479 if (m == SabrParametricVolatility::ModelVariant::Hagan2002Lognormal) {
1480 out << "Hagan2002Lognormal";
1481 } else if (m == SabrParametricVolatility::ModelVariant::Hagan2002Normal) {
1482 out << "Hagan2002Normal";
1483 } else if (m == SabrParametricVolatility::ModelVariant::Hagan2002NormalZeroBeta) {
1484 out << "Hagan200NormalZeroBeta";
1485 } else if (m == SabrParametricVolatility::ModelVariant::Antonov2015FreeBoundaryNormal) {
1486 out << "AntonovNormalZeroBeta";
1487 } else if (m == SabrParametricVolatility::ModelVariant::KienitzLawsonSwaynePde) {
1488 out << "KienitzLawsonSwaynePde";
1489 } else if (m == SabrParametricVolatility::ModelVariant::FlochKennedy) {
1490 out << "FlochKennedy";
1491 } else {
1492 QL_FAIL("SabrParametricVolatility::ModelVariant (" << static_cast<int>(m)
1493 << ") not recognized. This is an internal error.");
1494 }
1495 return out;
1496}
1497
1498std::ostream& operator<<(std::ostream& os, Exercise::Type type) {
1499 if (type == Exercise::European) {
1500 os << "European";
1501 } else if (type == Exercise::Bermudan) {
1502 os << "Bermudan";
1503 } else if (type == Exercise::American) {
1504 os << "American";
1505 } else {
1506 QL_FAIL("Exercise::Type (" << static_cast<int>(type)
1507 << " not recognized. Expected 'European', 'Bermudan', or 'American'.");
1508 }
1509
1510 return os;
1511}
1512
1513} // namespace data
1514} // namespace ore
calendar parser singleton class
CalculationPeriod
Indicate location of calculation period relative to the future expiry date.
PublicationRoll
Rule for determining when inflation swaps roll to observing latest inflation index release.
Type
Type of price segment being represented, i.e. type of instrument in the price segment.
SafeStack< ValueType > value
currency parser singleton class
DateGeneration::Rule parseDateGenerationRule(const string &s)
Convert text to QuantLib::DateGeneration::Rule.
Definition: parsers.cpp:328
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
CdsOption::StrikeType parseCdsOptionStrikeType(const string &s)
Definition: parsers.cpp:1240
Exercise::Type parseExerciseType(const std::string &s)
Convert text to QuantLib::Exercise::Type.
Definition: parsers.cpp:466
Currency parseMinorCurrency(const string &s)
Convert text to QuantLib::Currency for minor currencies e.g GBp -> GBPCurrency()
Definition: parsers.cpp:308
Month parseMonth(const string &s)
Definition: parsers.cpp:613
QuantExt::ConfigurableCurrency::Type parseCurrencyType(const string &s)
Convert text to QuantExt::ConfigurableCurrency::Type (Major, Minor, Metal, Crypto)
Definition: parsers.cpp:292
MporCashFlowMode parseMporCashFlowMode(const string &s)
Convert text to MporCashFlowMode.
Definition: parsers.cpp:1428
YoYInflationCapFloor::Type parseYoYInflationCapFloorType(const string &s)
Definition: parsers.cpp:827
SequenceType parseSequenceType(const std::string &s)
Convert string to sequence type.
Definition: parsers.cpp:668
bool tryParseReal(const string &s, QuantLib::Real &result)
Attempt to convert text to Real.
Definition: parsers.cpp:126
VolatilityType parseVolatilityQuoteType(const string &s)
Definition: parsers.cpp:804
QuantLib::LsmBasisSystem::PolynomialType parsePolynomType(const std::string &s)
Convert text to QuantLib::LsmBasisSystem::PolynomialType.
Definition: parsers.cpp:527
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, const bool useConventions)
Convert std::string to QuantExt::FxIndex.
DoubleBarrier::Type parseDoubleBarrierType(const std::string &s)
Convert std::string to QuantLib::DoubleBarrierType.
Definition: parsers.cpp:1061
pair< string, string > parseBoostAny(const boost::any &anyType, Size precision)
Definition: parsers.cpp:859
Settlement::Method parseSettlementMethod(const std::string &s)
Convert text to QuantLib::Settlement::Method.
Definition: parsers.cpp:450
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:310
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
QuantLib::Real convertMinorToMajorCurrency(const std::string &s, QuantLib::Real value)
Convert a value from a minor ccy to major.
Definition: parsers.cpp:324
boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod(const string &s)
Convert text to QuantLib::Period or QuantLib::Date.
Definition: parsers.cpp:493
bool isCryptoCurrency(const string &code)
check for crypto currency *‍/
Definition: parsers.cpp:322
bool isPreciousMetal(const string &code)
check for precious metal *‍/
Definition: parsers.cpp:320
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant(const std::string &s)
Parse SabrParametricVolatility::ModelVariant.
Definition: parsers.cpp:1458
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
QuantLib::Pillar::Choice parsePillarChoice(const std::string &s)
Convert text to QuantLib::Pillar::Choice.
Definition: parsers.cpp:1403
CapFloor::Type parseCapFloorType(const string &s)
Definition: parsers.cpp:815
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
Definition: parsers.cpp:173
QuantLib::CPI::InterpolationType parseObservationInterpolation(const std::string &s)
Convert string to observation interpolation.
Definition: parsers.cpp:682
AssetClass parseAssetClass(const std::string &s)
Convert text to ore::data::AssetClass.
Definition: parsers.cpp:710
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
Frequency parseFrequency(const string &s)
Convert text to QuantLib::Frequency.
Definition: parsers.cpp:348
string fxDominance(const string &s1, const string &s2)
Convert FX pair to market standard dominance.
Definition: parsers.cpp:1296
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
pair< Currency, Currency > parseCurrencyPair(const string &s, const string &delimiters)
Convert text to std::pair<QuantLib::Currency, QuantLib::Currency>
Definition: parsers.cpp:312
QuantLib::Bond::Price::Type parseBondPriceType(const string &s)
Convert text to QuantLib::Bond::Price::Type.
Definition: parsers.cpp:392
Compounding parseCompounding(const string &s)
Convert text to QuantLib::Compounding;.
Definition: parsers.cpp:376
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers(const std::string &s)
Convert text to QuantLib::SobolRsg::DirectionIntegers.
Definition: parsers.cpp:579
QuantExt::BondIndex::PriceQuoteMethod parsePriceQuoteMethod(const std::string &s)
Definition: parsers.cpp:1261
Weekday parseWeekday(const string &s)
Definition: parsers.cpp:599
PaymentLag parsePaymentLag(const string &s)
Convert text to PaymentLag.
Definition: parsers.cpp:628
Real parseRealOrNull(const string &s)
Convert text to Real, empty string to Null<Real>()
Definition: parsers.cpp:120
Barrier::Type parseBarrierType(const std::string &s)
Convert std::string to QuantLib::BarrierType.
Definition: parsers.cpp:1042
bool isPseudoCurrency(const string &code)
check for pseudo currency = precious metal or crypto currency *‍/
Definition: parsers.cpp:318
MomentType parseMomentType(const std::string &s)
Convert text to ore::data::MomentType.
Definition: parsers.cpp:1361
DeltaVolQuote::AtmType parseAtmType(const std::string &s)
Convert text to QuantLib::DeltaVolQuote::AtmType.
Definition: parsers.cpp:746
Average::Type parseAverageType(const std::string &s)
Definition: parsers.cpp:1251
QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel(const std::string &s)
Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel.
Definition: parsers.cpp:1418
Protection::Side parseProtectionSide(const std::string &s)
Convert text to QuantLib::Protection::Side.
Definition: parsers.cpp:420
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering(const std::string &s)
Convert text to QuantLib::SobolBrownianGenerator::Ordering.
Definition: parsers.cpp:567
QuantLib::Rounding::Type parseRoundingType(const std::string &s)
Convert text to QuantLib::Rounding.
Definition: parsers.cpp:1027
bool checkCurrency(const string &code)
check for vaid currency code, including minors and pseudo currencies
Definition: parsers.cpp:316
QuantExt::CrossAssetModel::AssetType parseCamAssetType(const string &s)
Definition: parsers.cpp:839
FdmSchemeDesc parseFdmSchemeDesc(const std::string &s)
Convert string to fdm scheme desc.
Definition: parsers.cpp:692
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
Settlement::Type parseSettlementType(const std::string &s)
Convert text to QuantLib::Settlement::Type.
Definition: parsers.cpp:434
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Definition: parsers.cpp:209
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
Definition: parsers.cpp:481
DeltaVolQuote::DeltaType parseDeltaType(const std::string &s)
Convert text to QuantLib::DeltaVolQuote::DeltaType.
Definition: parsers.cpp:763
Map text representations to QuantLib/QuantExt types.
@ data
Definition: log.hpp:77
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
CommodityQuantityFrequency
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
std::vector< std::string > getCorrelationTokens(const std::string &name)
Helper function to get the two tokens in a correlation name Index2:Index1.
Definition: parsers.cpp:1281
string normaliseFxIndex(const std::string &indexName)
Convert FX index name to market standard dominance.
Definition: parsers.cpp:1351
bool isOnePeriod(const string &s)
return true if s represents a period of the form [0-9][D|W|M|Y] (i.e. 1Y6M would return false)
Definition: parsers.cpp:159
ADCP parseAveragingDataPeriod(const string &s)
Convert text to CommodityFutureConvention::AveragingData::CalculationPeriod.
Definition: parsers.cpp:1136
std::vector< string > parseListOfValues(string s, const char escape, const char delim, const char quote)
Definition: parsers.cpp:639
CreditPortfolioSensitivityDecomposition parseCreditPortfolioSensitivityDecomposition(const std::string &s)
Convert text to CreditPortfolioSensitivitiyDecomposition.
Definition: parsers.cpp:1374
FutureConvention::DateGenerationRule parseFutureDateGenerationRule(const std::string &s)
Convert text to FutureConvention::DateGeneration.
Definition: parsers.cpp:991
MporCashFlowMode
Definition: parsers.hpp:588
@ Unspecified
Definition: parsers.hpp:588
Size size(const ValueType &v)
Definition: value.cpp:145
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Extrapolation
Enumeration for holding various extrapolation settings.
Definition: parsers.hpp:450
CommodityQuantityFrequency parseCommodityQuantityFrequency(const string &s)
Convert text to QuantExt::CommodityQuantityFrequency.
Definition: parsers.cpp:1192
InflationSwapConvention::PublicationRoll parseInflationSwapPublicationRoll(const string &s)
Convert text to InflationSwapConvention::PublicationRoll.
Definition: parsers.cpp:1012
CreditPortfolioSensitivityDecomposition
Enumeration CreditPortfolioSensitivityDecomposition.
Definition: parsers.hpp:568
AmortizationType parseAmortizationType(const std::string &s)
Definition: parsers.cpp:651
std::string inverseFxIndex(const std::string &indexName)
boost::variant< QuantLib::Period, QuantLib::Natural > PaymentLag
Definition: types.hpp:32
QuantLib::RateAveraging::Type parseOvernightIndexFutureNettingType(const std::string &s)
Convert text to QuantLib::RateAveraging::Type.
Definition: parsers.cpp:970
Extrapolation parseExtrapolation(const string &s)
Parse Extrapolation from string.
Definition: parsers.cpp:778
PriceSegment::Type parsePriceSegmentType(const string &s)
Convert text to PriceSegment::Type.
Definition: parsers.cpp:1158
AmortizationType
Definition: parsers.hpp:346
Serializable Credit Default Swap.
Definition: namespaces.docs:23
bool & res_is_date
Definition: parsers.cpp:518
Date & res_d
Definition: parsers.cpp:516
Period & res_p
Definition: parsers.cpp:517
Map text representations to QuantLib/QuantExt types.
string conversion utilities
string name