25#include <boost/algorithm/string.hpp>
32#include <ql/errors.hpp>
33#include <ql/indexes/all.hpp>
34#include <ql/time/daycounters/all.hpp>
35#include <ql/utilities/dataparsers.hpp>
39#include <boost/lexical_cast.hpp>
46using boost::algorithm::to_lower_copy;
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");
62 vector<string> tokens;
63 boost::split(tokens, s, boost::is_any_of(
"-/.:"));
65 if (tokens.size() == 1) {
71 return Date(d, Month(m), y);
72 }
else if (s.size() >= 3 && s.size() <= 6) {
80 }
else if (tokens.size() == 3) {
81 if (tokens[0].
size() == 4) {
88 return Date(d, Month(m), y);
89 }
else if (tokens[0].
size() == 2) {
105 return Date(d, Month(m), y);
109 QL_FAIL(
"Cannot convert \"" << s <<
"\" to Date.");
115 }
catch (
const std::exception& ex) {
116 QL_FAIL(
"Failed to parseReal(\"" << s <<
"\") " << ex.what());
128 result = std::stod(s);
130 result = Null<Real>();
138 return boost::lexical_cast<Integer>(s.c_str());
139 }
catch (std::exception& ex) {
140 QL_FAIL(
"Failed to parseInteger(\"" << s <<
"\") " << ex.what());
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}};
153 QL_FAIL(
"Cannot convert \"" << s <<
"\" to bool");
157Calendar
parseCalendar(
const string& s) {
return CalendarParser::instance().parseCalendar(s); }
162 char c = std::toupper(s.back());
163 if (!(c ==
'D' || c ==
'W' || c ==
'M' || c ==
'Y'))
165 for (
auto c = s.cbegin(); c != std::next(s.end(), -1); std::advance(c, 1))
166 if (*c < '0' || *c >
'9')
171Period
parsePeriod(
const string& s) {
return PeriodParser::parse(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},
183 {
"Preceding", Preceding},
184 {
"PRECEDING", Preceding},
185 {
"MP", ModifiedPreceding},
186 {
"ModifiedPreceding", ModifiedPreceding},
187 {
"Modified Preceding", ModifiedPreceding},
188 {
"MODIFIEDP", ModifiedPreceding},
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}};
205 QL_FAIL(
"Cannot convert \"" << s <<
"\" to BusinessDayConvention");
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()},
276 {
"A364", QuantLib::Actual364()},
277 {
"Actual/364", Actual364()},
278 {
"Act/364", Actual364()},
279 {
"ACT/364", Actual364()}};
286 QL_FAIL(
"DayCounter \"" << s <<
"\" not recognized");
290Currency
parseCurrency(
const string& s) {
return CurrencyParser::instance().parseCurrency(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}};
303 QL_FAIL(
"Currency type \"" << s <<
"\" not recognised");
308Currency
parseMinorCurrency(
const string& s) {
return CurrencyParser::instance().parseMinorCurrency(s); }
313 return CurrencyParser::instance().parseCurrencyPair(s, delimiters);
316bool checkCurrency(
const string& code) {
return CurrencyParser::instance().isValidCurrency(code); }
318bool isPseudoCurrency(
const string& code) {
return CurrencyParser::instance().isPseudoCurrency(code); }
320bool isPreciousMetal(
const string& code) {
return CurrencyParser::instance().isPreciousMetal(code); }
322bool isCryptoCurrency(
const string& code) {
return CurrencyParser::instance().isCryptoCurrency(code); }
325 return CurrencyParser::instance().convertMinorToMajorCurrency(s,
value);
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}};
344 QL_FAIL(
"Date Generation Rule \"" << s <<
"\" not recognized");
349 static map<string, Frequency> m = {{
"Z", Once},
354 {
"Semiannual", Semiannual},
356 {
"Quarterly", Quarterly},
358 {
"Bimonthly", Bimonthly},
360 {
"Monthly", Monthly},
361 {
"L", EveryFourthWeek},
362 {
"Lunarmonth", EveryFourthWeek},
372 QL_FAIL(
"Frequency \"" << s <<
"\" not recognized");
377 static map<string, Compounding> m = {
379 {
"Compounded", Compounded},
380 {
"Continuous", Continuous},
381 {
"SimpleThenCompounded", SimpleThenCompounded},
388 QL_FAIL(
"Compounding \"" << s <<
"\" not recognized");
393 static map<string, QuantLib::Bond::Price::Type> m = {{
"Clean", QuantLib::Bond::Price::Type::Clean},
394 {
"Dirty", QuantLib::Bond::Price::Type::Dirty}};
400 QL_FAIL(
"BondPriceType \"" << s <<
"\" not recognized");
405 static map<string, Position::Type> m = {
406 {
"Long", Position::Long},
407 {
"Short", Position::Short},
408 {
"L", Position::Long},
409 {
"S", Position::Short},
416 QL_FAIL(
"Position type \"" << s <<
"\" not recognized");
421 static map<string, Protection::Side> m = {{
"Buyer", Protection::Buyer},
422 {
"Seller", Protection::Seller},
423 {
"B", Protection::Buyer},
424 {
"S", Protection::Seller}};
430 QL_FAIL(
"Protection side \"" << s <<
"\" not recognized");
435 static map<string, Settlement::Type> m = {
436 {
"Cash", Settlement::Cash},
437 {
"Physical", Settlement::Physical},
438 {
"C", Settlement::Cash},
439 {
"P", Settlement::Physical},
446 QL_FAIL(
"Settlement type \"" << s <<
"\" not recognized");
451 static map<string, Settlement::Method> m = {
452 {
"PhysicalOTC", Settlement::PhysicalOTC},
453 {
"PhysicalCleared", Settlement::PhysicalCleared},
454 {
"CollateralizedCashPrice", Settlement::CollateralizedCashPrice},
455 {
"ParYieldCurve", Settlement::ParYieldCurve},
462 QL_FAIL(
"Settlement method \"" << s <<
"\" not recognized");
467 static map<string, Exercise::Type> m = {
468 {
"European", Exercise::European},
469 {
"Bermudan", Exercise::Bermudan},
470 {
"American", Exercise::American},
477 QL_FAIL(
"Exercise type \"" << s <<
"\" not recognized");
482 static map<string, Option::Type> m = {{
"Put", Option::Put}, {
"Call", Option::Call}};
484 QL_REQUIRE(!s.empty(),
"Option type not given.");
489 QL_FAIL(
"Option type \"" << s <<
"\" not recognized");
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;
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 {
512 void operator()(
const QuantLib::Period& p)
const {
524 boost::apply_visitor(legacy_date_or_period_visitor(d, p, isDate), r);
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},
538 auto it = poly.find(s);
539 if (it != poly.end()) {
542 QL_FAIL(
"Polynom type \"" << s <<
"\" not recognized");
546std::ostream&
operator<<(std::ostream& os, QuantLib::LsmBasisSystem::PolynomialType 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";
563 QL_FAIL(
"unknown LsmBasisSystem::PolynomialType '" <<
static_cast<int>(a) <<
"'");
568 static map<string, SobolBrownianGenerator::Ordering> m = {{
"Factors", SobolBrownianGenerator::Ordering::Factors},
569 {
"Steps", SobolBrownianGenerator::Ordering::Steps},
570 {
"Diagonal", SobolBrownianGenerator::Ordering::Diagonal}};
575 QL_FAIL(
"SobolBrownianGenerator ordering \"" << s <<
"\" not recognized");
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}};
595 QL_FAIL(
"SobolRsg direction integers \"" << s <<
"\" not recognized");
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}};
609 QL_FAIL(
"The string \"" << s <<
"\" is not recognized as a Weekday");
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}};
624 QL_FAIL(
"The string \"" << s <<
"\" is not recognized as a Month");
639std::vector<string>
parseListOfValues(
string s,
const char escape,
const char delim,
const char quote) {
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) {
652 static map<string, AmortizationType> type = {
660 auto it = type.find(s);
661 if (it != type.end()) {
664 QL_FAIL(
"Amortitazion type \"" << s <<
"\" not recognized");
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);
679 QL_FAIL(
"sequence type \"" << s <<
"\" not recognised");
683 static map<string, CPI::InterpolationType> seq = {
684 {
"Flat", CPI::Flat}, {
"Linear", CPI::Linear}, {
"AsIndex", CPI::AsIndex}};
685 auto it = seq.find(s);
689 QL_FAIL(
"observation interpolation type \"" << s <<
"\" not recognised");
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()}};
707 QL_FAIL(
"fdm scheme \"" << s <<
"\" not recognised");
715 auto it = assetClasses.find(s);
716 if (it != assetClasses.end()) {
719 QL_FAIL(
"AssetClass \"" << s <<
"\" not recognized");
740 return os <<
"BOND_INDEX";
742 QL_FAIL(
"Unknown AssetClass");
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}};
759 QL_FAIL(
"ATM type \"" << s <<
"\" not recognized");
764 static map<string, DeltaVolQuote::DeltaType> m = {{
"Spot", DeltaVolQuote::Spot},
765 {
"Fwd", DeltaVolQuote::Fwd},
766 {
"PaSpot", DeltaVolQuote::PaSpot},
767 {
"PaFwd", DeltaVolQuote::PaFwd}};
773 QL_FAIL(
"Delta type \"" << s <<
"\" not recognized");
781 }
else if (s ==
"UseInterpolator" || s ==
"Linear") {
783 }
else if (s ==
"Flat") {
786 QL_FAIL(
"Extrapolation '" << s <<
"' not recognized");
796 return os <<
"UseInterpolator";
800 QL_FAIL(
"Unknown Extrapolation");
808 }
else if (s ==
"ShiftedLognormal") {
809 return ShiftedLognormal;
811 QL_FAIL(
"Unknown volatility quote type " << s);
817 return CapFloor::Cap;
818 }
else if (s ==
"Floor") {
819 return CapFloor::Floor;
820 }
else if (s ==
"Collar") {
821 return CapFloor::Collar;
823 QL_FAIL(
"Unknown cap floor type " << 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;
835 QL_FAIL(
"Unknown year on year inflation cap floor type " << s);
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;
855 QL_FAIL(
"Unknown cross asset model type " << s);
859pair<string, string>
parseBoostAny(
const boost::any& anyType, Size precision) {
861 std::ostringstream oss;
863 if (anyType.type() ==
typeid(
int)) {
865 int r = boost::any_cast<int>(anyType);
866 oss << std::fixed << std::setprecision(precision) << r;
867 }
else if (anyType.type() ==
typeid(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)) {
882 oss << io::iso_date(boost::any_cast<Date>(anyType));
883 }
else if (anyType.type() ==
typeid(
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);
892 oss << std::boolalpha <<
"\"" << boost::any_cast<bool>(anyType);
893 for (Size i = 1; i < r.size(); i++) {
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);
904 oss << std::fixed << std::setprecision(precision) <<
"\"";
905 if (r[0] != Null<Real>())
907 for (Size i = 1; i < r.size(); i++) {
909 if (r[i] != Null<Real>())
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);
920 oss << std::fixed << std::setprecision(precision) <<
"\"" <<
to_string(r[0]);
921 for (Size i = 1; i < r.size(); i++) {
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);
932 oss << std::fixed << std::setprecision(precision) <<
"\"" << r[0];
933 for (Size i = 1; i < r.size(); i++) {
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);
942 oss << std::fixed << std::setprecision(precision) <<
"\"" << r[0];
943 for (Size i = 1; i < r.size(); ++i) {
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);
964 ALOG(
"Unsupported Boost::Any type");
965 resultType =
"unsupported_type";
967 return make_pair(resultType, oss.str());
971 if (s ==
"Averaging") {
972 return QuantLib::RateAveraging::Type::Simple;
973 }
else if (s ==
"Compounding") {
974 return QuantLib::RateAveraging::Type::Compound;
976 QL_FAIL(
"Overnight Index Future Netting Type '" << s <<
"' not known, expected 'Averaging' or 'Compounding'");
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";
986 QL_FAIL(
"Internal error: unknown RateAveraging::Type - check implementation of operator<< "
994 else if (s ==
"FirstDayOfMonth")
997 QL_FAIL(
"FutureConvention / DateGenerationRule '" << s <<
"' not known, expect 'IMM' or 'FirstDayOfMonth'");
1005 return os <<
"FirstDayOfMonth";
1007 QL_FAIL(
"Internal error: unknown FutureConvention::DateGenerationRule - check implementation of operator<< "
1016 }
else if (s ==
"OnPublicationDate") {
1017 return IPR::OnPublicationDate;
1018 }
else if (s ==
"AfterPublicationDate") {
1019 return IPR::AfterPublicationDate;
1021 QL_FAIL(
"InflationSwapConvention::PublicationRoll '"
1022 << s <<
"' not known, expect "
1023 <<
"'None', 'OnPublicationDate' or 'AfterPublicationDate'");
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}};
1034 auto it = m.find(s);
1035 if (it != m.end()) {
1038 QL_FAIL(
"Rounding type \"" << s <<
"\" not recognized");
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},
1048 {
"Down&In", Barrier::Type::DownIn},
1049 {
"Up&In", Barrier::Type::UpIn},
1050 {
"Down&Out", Barrier::Type::DownOut},
1051 {
"Up&Out", Barrier::Type::UpOut}};
1053 auto it = type.find(s);
1054 if (it != type.end()) {
1057 QL_FAIL(
"Barrier type \"" << s <<
"\" not recognized");
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},
1069 auto it = type.find(s);
1070 if (it != type.end()) {
1073 QL_FAIL(
"DoubleBarrier type \"" << s <<
"\" not recognized");
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";
1086 QL_FAIL(
"Unknown InflationSwapConvention::PublicationRoll.");
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;
1098 QL_FAIL(
"Internal error: unknown SobolBrownianGenerator::Ordering - check implementation of operator<< "
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;
1119 QL_FAIL(
"Internal error: unknown SobolRsg::DirectionIntegers - check implementation of operator<< "
1126 case QuantExt::CrossAssetModel::Discretization::Exact:
1127 return out <<
"Exact";
1128 case QuantExt::CrossAssetModel::Discretization::Euler:
1129 return out <<
"Euler";
1137 if (s ==
"PreviousMonth") {
1138 return ADCP::PreviousMonth;
1139 }
else if (s ==
"ExpiryToExpiry") {
1140 return ADCP::ExpiryToExpiry;
1142 QL_FAIL(
"AveragingData::CalculationPeriod '" << s <<
"' not known, expect "
1143 <<
"'PreviousMonth' or 'ExpiryToExpiry'");
1148 if (cp == ADCP::PreviousMonth) {
1149 return os <<
"PreviousMonth";
1150 }
else if (cp == ADCP::ExpiryToExpiry) {
1151 return os <<
"ExpiryToExpiry";
1153 QL_FAIL(
"Unknown AveragingData::CalculationPeriod.");
1159 if (s ==
"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;
1170 QL_FAIL(
"PriceSegment::Type '" << s <<
"' not known, expect "
1171 <<
"'Future', 'AveragingFuture' or 'AveragingSpot'");
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";
1187 QL_FAIL(
"Unknown PriceSegment::Type.");
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;
1204 QL_FAIL(
"Could not parse " << s <<
" to CommodityQuantityFrequency");
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";
1220 QL_FAIL(
"Do not recognise CommodityQuantityFrequency " <<
static_cast<int>(cqf));
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;
1234 QL_FAIL(
"Internal error: unknown Rounding::Type - check implementation of operator<< "
1242 if (s ==
"Spread") {
1244 }
else if (s ==
"Price") {
1247 QL_FAIL(
"CdsOption::StrikeType \"" << s <<
"\" not recognized");
1252 if (s ==
"Arithmetic") {
1253 return Average::Type::Arithmetic;
1254 }
else if (s ==
"Geometric") {
1255 return Average::Type::Geometric;
1257 QL_FAIL(
"Average::Type '" << s <<
"' not recognized. Should be Arithmetic or Geometric");
1262 if (s ==
"CurrencyPerUnit")
1263 return QuantExt::BondIndex::PriceQuoteMethod::CurrencyPerUnit;
1264 else if (s ==
"PercentageOfPar")
1265 return QuantExt::BondIndex::PriceQuoteMethod::PercentageOfPar;
1267 QL_FAIL(
"PriceQuoteMethod '" << s <<
"' not recognized. Expected CurrencyPerUnit or PercentageOfPar.");
1272 if (p == QuantExt::BondIndex::PriceQuoteMethod::PercentageOfPar)
1273 os <<
"PercentageOfPar";
1274 else if (p == QuantExt::BondIndex::PriceQuoteMethod::CurrencyPerUnit)
1275 os <<
"CurrencyPerUnit";
1277 os <<
"Unknown PriceQuoteMethod (" <<
static_cast<int>(p) <<
")";
1285 if (
name.find(
'&') != std::string::npos)
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");
1306 static vector<string> dominance = {
1308 "XAU",
"XAG",
"XPT",
"XPD",
1310 "EUR",
"GBP",
"AUD",
"NZD",
"USD",
"CAD",
"CHF",
"ZAR",
1313 "DKK",
"NOK",
"SEK",
1314 "HKD",
"THB",
"TWD",
"MXN",
1322 auto p1 = std::find(dominance.begin(), dominance.end(), s1);
1323 auto p2 = std::find(dominance.begin(), dominance.end(), s2);
1326 if (p1 != dominance.end() && p2 != dominance.end()) {
1333 if (p1 == dominance.end() && p2 == dominance.end()) {
1334 WLOG(
"No dominance for either " << s1 <<
" or " << s2 <<
" assuming " << s1 + s2);
1341 else if (s2 ==
"JPY")
1344 if (p1 != dominance.end())
1353 std::string ccy1 = fx->sourceCurrency().code();
1354 std::string ccy2 = fx->targetCurrency().code();
1362 static map<string, MomentType> momentTypes = {
1366 auto it = momentTypes.find(s);
1367 if (it != momentTypes.end()) {
1370 QL_FAIL(
"momentTypes \"" << s <<
"\" not recognized");
1375 if (s ==
"Underlying") {
1377 }
else if (s ==
"NotionalWeighted") {
1379 }
else if (s ==
"LossWeighted") {
1381 }
else if (s ==
"DeltaWeighted") {
1384 QL_FAIL(
"CreditPortfolioSensitivityDecomposition '"
1385 << s <<
"' invalid, expected Underlying, NotionalWeighted, LossWeighted, DeltaWeighted");
1391 return os <<
"Underlying";
1393 return os <<
"NotionalWeighted";
1395 return os <<
"LossWeighted";
1397 return os <<
"DeltaWeighted";
1399 QL_FAIL(
"Unknonw CreditPortfolioSensitivitiyDecomposition value " <<
static_cast<std::size_t
>(d));
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;
1414 QL_FAIL(
"PillarChoice '" << s <<
"' not recognized, expected MaturityDate, LastRelevantDate, CustomDate");
1420 return McMultiLegBaseEngine::RegressorModel::Simple;
1421 else if (s ==
"LaggedFX")
1422 return McMultiLegBaseEngine::RegressorModel::LaggedFX;
1424 QL_FAIL(
"RegressorModel '" << s <<
"' not recognized, expected Simple, LaggedFX");
1434 auto it = m.find(s);
1435 if (it != m.end()) {
1438 QL_FAIL(
"Mpor cash flow mode \"" << s <<
"\" not recognized");
1443 out <<
"Unspecified";
1453 QL_FAIL(
"Mpor cash flow mode not covered, expected one of 'Unspecified', 'NonePay', 'BothPay', 'WePay', "
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()) {
1471 "SabrParametricVolatilityModelVariant '"
1473 <<
"' not recognized, expected one of 'Hagan2002Lognormal', 'Hagan2002Normal', 'Hagan2002NormalZeroBeta', "
1474 "'Antonov2015FreeBoundaryNormal', 'KienitzLawsonSwaynePde', 'FlochKennedy'.");
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";
1492 QL_FAIL(
"SabrParametricVolatility::ModelVariant (" <<
static_cast<int>(m)
1493 <<
") not recognized. This is an internal error.");
1499 if (type == Exercise::European) {
1501 }
else if (type == Exercise::Bermudan) {
1503 }
else if (type == Exercise::American) {
1506 QL_FAIL(
"Exercise::Type (" <<
static_cast<int>(type)
1507 <<
" not recognized. Expected 'European', 'Bermudan', or 'American'.");
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.
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
CdsOption::StrikeType parseCdsOptionStrikeType(const string &s)
Exercise::Type parseExerciseType(const std::string &s)
Convert text to QuantLib::Exercise::Type.
Currency parseMinorCurrency(const string &s)
Convert text to QuantLib::Currency for minor currencies e.g GBp -> GBPCurrency()
Month parseMonth(const string &s)
QuantExt::ConfigurableCurrency::Type parseCurrencyType(const string &s)
Convert text to QuantExt::ConfigurableCurrency::Type (Major, Minor, Metal, Crypto)
MporCashFlowMode parseMporCashFlowMode(const string &s)
Convert text to MporCashFlowMode.
YoYInflationCapFloor::Type parseYoYInflationCapFloorType(const string &s)
SequenceType parseSequenceType(const std::string &s)
Convert string to sequence type.
bool tryParseReal(const string &s, QuantLib::Real &result)
Attempt to convert text to Real.
VolatilityType parseVolatilityQuoteType(const string &s)
QuantLib::LsmBasisSystem::PolynomialType parsePolynomType(const std::string &s)
Convert text to QuantLib::LsmBasisSystem::PolynomialType.
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.
pair< string, string > parseBoostAny(const boost::any &anyType, Size precision)
Settlement::Method parseSettlementMethod(const std::string &s)
Convert text to QuantLib::Settlement::Method.
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
QuantLib::Real convertMinorToMajorCurrency(const std::string &s, QuantLib::Real value)
Convert a value from a minor ccy to major.
boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod(const string &s)
Convert text to QuantLib::Period or QuantLib::Date.
bool isCryptoCurrency(const string &code)
check for crypto currency */
bool isPreciousMetal(const string &code)
check for precious metal */
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant(const std::string &s)
Parse SabrParametricVolatility::ModelVariant.
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
QuantLib::Pillar::Choice parsePillarChoice(const std::string &s)
Convert text to QuantLib::Pillar::Choice.
CapFloor::Type parseCapFloorType(const string &s)
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
QuantLib::CPI::InterpolationType parseObservationInterpolation(const std::string &s)
Convert string to observation interpolation.
AssetClass parseAssetClass(const std::string &s)
Convert text to ore::data::AssetClass.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Frequency parseFrequency(const string &s)
Convert text to QuantLib::Frequency.
string fxDominance(const string &s1, const string &s2)
Convert FX pair to market standard dominance.
bool parseBool(const string &s)
Convert text to bool.
pair< Currency, Currency > parseCurrencyPair(const string &s, const string &delimiters)
Convert text to std::pair<QuantLib::Currency, QuantLib::Currency>
QuantLib::Bond::Price::Type parseBondPriceType(const string &s)
Convert text to QuantLib::Bond::Price::Type.
Compounding parseCompounding(const string &s)
Convert text to QuantLib::Compounding;.
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers(const std::string &s)
Convert text to QuantLib::SobolRsg::DirectionIntegers.
QuantExt::BondIndex::PriceQuoteMethod parsePriceQuoteMethod(const std::string &s)
Weekday parseWeekday(const string &s)
PaymentLag parsePaymentLag(const string &s)
Convert text to PaymentLag.
Real parseRealOrNull(const string &s)
Convert text to Real, empty string to Null<Real>()
Barrier::Type parseBarrierType(const std::string &s)
Convert std::string to QuantLib::BarrierType.
bool isPseudoCurrency(const string &code)
check for pseudo currency = precious metal or crypto currency */
MomentType parseMomentType(const std::string &s)
Convert text to ore::data::MomentType.
DeltaVolQuote::AtmType parseAtmType(const std::string &s)
Convert text to QuantLib::DeltaVolQuote::AtmType.
Average::Type parseAverageType(const std::string &s)
QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel(const std::string &s)
Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel.
Protection::Side parseProtectionSide(const std::string &s)
Convert text to QuantLib::Protection::Side.
Real parseReal(const string &s)
Convert text to Real.
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering(const std::string &s)
Convert text to QuantLib::SobolBrownianGenerator::Ordering.
QuantLib::Rounding::Type parseRoundingType(const std::string &s)
Convert text to QuantLib::Rounding.
bool checkCurrency(const string &code)
check for vaid currency code, including minors and pseudo currencies
QuantExt::CrossAssetModel::AssetType parseCamAssetType(const string &s)
FdmSchemeDesc parseFdmSchemeDesc(const std::string &s)
Convert string to fdm scheme desc.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Settlement::Type parseSettlementType(const std::string &s)
Convert text to QuantLib::Settlement::Type.
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
DeltaVolQuote::DeltaType parseDeltaType(const std::string &s)
Convert text to QuantLib::DeltaVolQuote::DeltaType.
Map text representations to QuantLib/QuantExt types.
#define ALOG(text)
Logging Macro (Level = Alert)
#define WLOG(text)
Logging Macro (Level = Warning)
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.
string normaliseFxIndex(const std::string &indexName)
Convert FX index name to market standard dominance.
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)
ADCP parseAveragingDataPeriod(const string &s)
Convert text to CommodityFutureConvention::AveragingData::CalculationPeriod.
std::vector< string > parseListOfValues(string s, const char escape, const char delim, const char quote)
CreditPortfolioSensitivityDecomposition parseCreditPortfolioSensitivityDecomposition(const std::string &s)
Convert text to CreditPortfolioSensitivitiyDecomposition.
FutureConvention::DateGenerationRule parseFutureDateGenerationRule(const std::string &s)
Convert text to FutureConvention::DateGeneration.
Size size(const ValueType &v)
std::string to_string(const LocationInfo &l)
Extrapolation
Enumeration for holding various extrapolation settings.
CommodityQuantityFrequency parseCommodityQuantityFrequency(const string &s)
Convert text to QuantExt::CommodityQuantityFrequency.
InflationSwapConvention::PublicationRoll parseInflationSwapPublicationRoll(const string &s)
Convert text to InflationSwapConvention::PublicationRoll.
CreditPortfolioSensitivityDecomposition
Enumeration CreditPortfolioSensitivityDecomposition.
AmortizationType parseAmortizationType(const std::string &s)
std::string inverseFxIndex(const std::string &indexName)
boost::variant< QuantLib::Period, QuantLib::Natural > PaymentLag
QuantLib::RateAveraging::Type parseOvernightIndexFutureNettingType(const std::string &s)
Convert text to QuantLib::RateAveraging::Type.
Extrapolation parseExtrapolation(const string &s)
Parse Extrapolation from string.
PriceSegment::Type parsePriceSegmentType(const string &s)
Convert text to PriceSegment::Type.
@ RelativeToPreviousNotional
@ RelativeToInitialNotional
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities