Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Files | Classes | Functions
Utilities

Files

file  calendaradjustmentconfig.hpp
 Interface for calendar modifications, additional holidays and business days.
 
file  iborfallbackconfig.hpp
 ibor fallback configuration
 
file  blackscholesmodelbuilder.hpp
 builder for an array of black scholes processes
 
file  blackscholesmodelbuilderbase.hpp
 builder for an array of black scholes processes
 
file  calibrationpointcache.hpp
 cache for relevant points on curve / vol surfaces
 
file  localvolmodelbuilder.hpp
 builder for an array of local vol processes
 
file  commodityapomodelbuilder.hpp
 model builder for commodityapos
 
file  ast.hpp
 abstract syntax tree for payoff scripting
 
file  astprinter.hpp
 ast printer
 
file  asttoscriptconverter.hpp
 ast to script converter
 
file  computationgraphbuilder.hpp
 computation graph builder
 
file  context.hpp
 script engine context holding variable names and values
 
file  grammar.hpp
 payoff script grammar
 
file  amcmodel.hpp
 additional interface for amc enabled models
 
file  blackscholes.hpp
 black scholes model for n underlyings (fx, equity or commodity)
 
file  blackscholesbase.hpp
 black scholes model base class for n underlyings (fx, equity or commodity)
 
file  blackscholescg.hpp
 black scholes model for n underlyings (fx, equity or commodity)
 
file  blackscholescgbase.hpp
 black scholes model base class for n underlyings (fx, equity or commodity)
 
file  dummymodel.hpp
 dummy model implementation
 
file  fdgaussiancam.hpp
 fd gaussian cross asset model for single underlying ir model
 
file  gaussiancam.hpp
 gaussian cross asset model for ir, fx, eq, com
 
file  gaussiancamcg.hpp
 Gaussian CAM model.
 
file  localvol.hpp
 local vol model for n underlyings (fx, equity or commodity)
 
file  model.hpp
 interface for model against which a script can be run
 
file  modelcg.hpp
 interface for model against which a script can be run
 
file  modelcgimpl.hpp
 basis implementation for a script engine model
 
file  modelimpl.hpp
 basis implementation for a script engine model
 
file  randomastgenerator.hpp
 random ast generator for testing purposes
 
file  safestack.hpp
 stack with safety checks and pop() that returns rvalue reference of top element
 
file  scriptengine.hpp
 scriptengine
 
file  scriptparser.hpp
 script parser
 
file  staticanalyser.hpp
 static script analyser
 
file  utilities.hpp
 some utility functions
 
file  value.hpp
 value type and operations
 
file  bondindexbuilder.hpp
 Interface for building a bond index.
 
file  calendaradjustmentconfig.hpp
 Interface for calendar modifications, additional holidays and business days.
 
file  calendarparser.hpp
 calendar parser singleton class
 
file  calendarparser.hpp
 calendar parser singleton class
 
file  conventionsbasedfutureexpiry.hpp
 Base class for classes that perform date calculations for future contracts.
 
file  correlationmatrix.hpp
 configuration class for building correlation matrices
 
file  csvfilereader.hpp
 utility class to access CSV files
 
file  calendarparser.hpp
 calendar parser singleton class
 
file  currencyparser.hpp
 currency parser singleton class
 
file  fileio.hpp
 Wrapper class for retrying file IO operations.
 
file  flowanalysis.hpp
 Extended QuantLib flow analysis.
 
file  indexnametranslator.hpp
 translates between QuantLib::Index::name() and ORE names
 
file  indexparser.cpp
 
file  indexparser.hpp
 Map text representations to QuantLib/QuantExt types.
 
file  indexparser.hpp
 Map text representations to QuantLib/QuantExt types.
 
file  log.hpp
 Classes and functions for log message handling.
 
file  marketdata.hpp
 market data related utilties
 
file  osutils.hpp
 Various OS specific utilities.
 
file  parsers.cpp
 
file  parsers.hpp
 Map text representations to QuantLib/QuantExt types.
 
file  progressbar.hpp
 Classes for progress reporting.
 
file  serializationdate.hpp
 support for QuantLib::Date serialization
 
file  serializationdaycounter.hpp
 support for QuantLib::DayCounter serialization
 
file  serializationperiod.hpp
 support for QuantLib::Period serialization
 
file  strike.hpp
 strike description
 
file  timeperiod.hpp
 non-contiguous time period handling
 
file  to_string.cpp
 
file  to_string.hpp
 string conversion utilities
 
file  vectorutils.hpp
 Utilities for sorting vectors using permutations.
 
file  wildcard.hpp
 utilities for wildcard handling
 
file  wildcard.hpp
 utilities for wildcard handling
 
file  xmlutils.cpp
 
file  xmlutils.hpp
 XML utility functions.
 

Classes

class  CorrelationMatrixBuilder
 
class  Logger
 The Base Custom Log Handler class. More...
 
class  StderrLogger
 Stderr Logger. More...
 
class  FileLogger
 FileLogger. More...
 
class  BufferLogger
 BufferLogger. More...
 
class  IndependentLogger
 Base Log handler class that utilises Boost logging to create log sinks. More...
 
class  Log
 Global static Log class. More...
 
class  ProgressIndicator
 Abstract Base class for a Progress Indicator. More...
 
class  ProgressReporter
 Base class for a Progress Reporter. More...
 
class  SimpleProgressBar
 Simple Progress Bar. More...
 
class  ProgressLog
 Progress Logger that writes the progress using the LOG macro. More...
 
class  TimePeriod
 Handles non-contiguous time period. More...
 
class  xml_node< Ch >
 XML Node. More...
 
class  xml_document< Ch >
 XML Document. More...
 
class  XMLDocument
 Small XML Document wrapper class. More...
 
class  XMLSerializable
 Base class for all serializable classes. More...
 
class  XMLUtils
 XML Utilities Class. More...
 

Functions

bool tryParseCdsInformation (string strInfo, CdsReferenceInformation &cdsInfo)
 
vector< vector< string > > flowAnalysis (const QuantLib::Leg &)
 Flow Analysis. More...
 
QuantLib::ext::shared_ptr< FxIndexparseFxIndex (const string &s, const Handle< Quote > &fxSpot=Handle< Quote >(), const Handle< YieldTermStructure > &sourceYts=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &targetYts=Handle< YieldTermStructure >(), const bool useConventions=false)
 Convert std::string to QuantExt::FxIndex. More...
 
QuantLib::ext::shared_ptr< IborIndexparseIborIndex (const string &s, const Handle< YieldTermStructure > &h=Handle< YieldTermStructure >())
 Convert std::string to QuantLib::IborIndex. More...
 
QuantLib::ext::shared_ptr< IborIndexparseIborIndex (const std::string &strIndex, std::string &outTenor, const QuantLib::Handle< QuantLib::YieldTermStructure > &h=QuantLib::Handle< QuantLib::YieldTermStructure >())
 Convert std::string to QuantLib::IborIndex and return the tenor string component of the index. More...
 
bool tryParseIborIndex (const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
 Try to convert std::string to QuantLib::IborIndex. More...
 
bool isGenericIborIndex (const string &indexName)
 Return true if the indexName is that of a generic ibor index, otherwise false. More...
 
pair< bool, QuantLib::ext::shared_ptr< ZeroInflationIndex > > isInflationIndex (const string &indexName)
 
bool isEquityIndex (const std::string &indexName)
 Return true if the indexName is that of an EquityIndex, otherwise false. More...
 
bool isCommodityIndex (const std::string &indexName)
 Return true if the indexName is that of an CommodityIndex, otherwise false. More...
 
bool isGenericIndex (const string &indexName)
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2parseEquityIndex (const string &s)
 Convert std::string (e.g SP5) to QuantExt::EquityIndex. More...
 
QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex (const string &s, const Handle< YieldTermStructure > &forwarding=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &discounting=Handle< YieldTermStructure >())
 Convert std::string to QuantLib::SwapIndex. More...
 
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex (const string &s, const Handle< ZeroInflationTermStructure > &h=Handle< ZeroInflationTermStructure >())
 Convert std::string to QuantLib::ZeroInflationIndex. More...
 
QuantLib::ext::shared_ptr< BondIndexparseBondIndex (const string &s)
 Convert std::string to QuantExt::BondIndex. More...
 
QuantLib::ext::shared_ptr< ConstantMaturityBondIndexparseConstantMaturityBondIndex (const string &s)
 Convert std::string to QuantExt::ConstantMaturityBondIndex. More...
 
QuantLib::ext::shared_ptr< QuantExt::CommodityIndexparseCommodityIndex (const std::string &name, bool hasPrefix=true, const QuantLib::Handle< QuantExt::PriceTermStructure > &ts=QuantLib::Handle< QuantExt::PriceTermStructure >(), const QuantLib::Calendar &cal=QuantLib::NullCalendar(), const bool enforceFutureIndex=true)
 
QuantLib::ext::shared_ptr< QuantLib::Index > parseGenericIndex (const string &s)
 Convert std::string (GENERIC-...) to QuantExt::Index. More...
 
QuantLib::ext::shared_ptr< Index > parseIndex (const string &s)
 Convert std::string to QuantLib::Index. More...
 
bool isOvernightIndex (const std::string &indexName)
 Return true if the indexName is that of an overnight index, otherwise false. More...
 
bool isBmaIndex (const std::string &indexName)
 Return true if the indexName is that of an bma/sifma index, otherwise false. More...
 
string internalIndexName (const string &indexName)
 
string getOsName ()
 Returns the OS Name. More...
 
string getOsVersion ()
 Returns the OS Version. More...
 
string getCpuName ()
 Returns the CPU name (e.g. "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz". More...
 
unsigned int getNumberCores ()
 Returns the number of Cores available to the OS. More...
 
string getMemoryRAM ()
 Returns the total amount of memory available (installed RAM) More...
 
string getMemoryUsage ()
 Returns the current process memory usage. More...
 
string getPeakMemoryUsage ()
 Returns the current process peak memory usage. More...
 
unsigned long long getMemoryUsageBytes ()
 
unsigned long long getPeakMemoryUsageBytes ()
 Returns the current process peak memory usage in bytes. More...
 
string getUsername ()
 Returns the current username. More...
 
string getHostname ()
 Returns the machine name. More...
 
string getSystemDetails ()
 Returns all the above system details in a single string. More...
 
void dumpStacktrace ()
 Write the current stacktrace to stderr and LOG() with level = ALERT. More...
 
void setAssertHandler ()
 Set an assert handler that logs the stacktrace. More...
 
Date parseDate (const string &s)
 Convert std::string to QuantLib::Date. More...
 
Real parseReal (const string &s)
 Convert text to Real. More...
 
Real parseRealOrNull (const string &s)
 Convert text to Real, empty string to Null<Real>() More...
 
bool tryParseReal (const string &s, QuantLib::Real &result)
 Attempt to convert text to Real. More...
 
Integer parseInteger (const string &s)
 Convert text to QuantLib::Integer. More...
 
bool parseBool (const string &s)
 Convert text to bool. More...
 
Calendar parseCalendar (const string &s)
 Convert text to QuantLib::Calendar. More...
 
Period parsePeriod (const string &s)
 Convert text to QuantLib::Period. More...
 
BusinessDayConvention parseBusinessDayConvention (const string &s)
 Convert text to QuantLib::BusinessDayConvention. More...
 
DayCounter parseDayCounter (const string &s)
 Convert text to QuantLib::DayCounter. More...
 
Currency parseCurrency (const string &s)
 Convert text to QuantLib::Currency. More...
 
QuantExt::ConfigurableCurrency::Type parseCurrencyType (const string &s)
 Convert text to QuantExt::ConfigurableCurrency::Type (Major, Minor, Metal, Crypto) More...
 
Currency parseMinorCurrency (const string &s)
 Convert text to QuantLib::Currency for minor currencies e.g GBp -> GBPCurrency() More...
 
Currency parseCurrencyWithMinors (const string &s)
 Convert text to QuantLib::Currency. More...
 
pair< Currency, Currency > parseCurrencyPair (const string &s, const string &delimiters)
 Convert text to std::pair<QuantLib::Currency, QuantLib::Currency> More...
 
bool checkCurrency (const string &code)
 check for vaid currency code, including minors and pseudo currencies More...
 
bool isPseudoCurrency (const string &code)
 check for pseudo currency = precious metal or crypto currency *‍/ More...
 
bool isPreciousMetal (const string &code)
 check for precious metal *‍/ More...
 
bool isCryptoCurrency (const string &code)
 check for crypto currency *‍/ More...
 
QuantLib::Real convertMinorToMajorCurrency (const std::string &s, QuantLib::Real value)
 Convert a value from a minor ccy to major. More...
 
DateGeneration::Rule parseDateGenerationRule (const string &s)
 Convert text to QuantLib::DateGeneration::Rule. More...
 
Frequency parseFrequency (const string &s)
 Convert text to QuantLib::Frequency. More...
 
Compounding parseCompounding (const string &s)
 Convert text to QuantLib::Compounding;. More...
 
Position::Type parsePositionType (const string &s)
 Convert text to QuantLib::Position::Type. More...
 
Protection::Side parseProtectionSide (const string &s)
 Convert text to QuantLib::Protection::Side. More...
 
Settlement::Type parseSettlementType (const string &s)
 Convert text to QuantLib::Settlement::Type. More...
 
Settlement::Method parseSettlementMethod (const string &s)
 Convert text to QuantLib::Settlement::Method. More...
 
Exercise::Type parseExerciseType (const string &s)
 Convert text to QuantLib::Exercise::Type. More...
 
Option::Type parseOptionType (const string &s)
 Convert text to QuantLib::Option::Type. More...
 
QuantLib::Bond::Price::Type parseBondPriceType (const string &s)
 Convert text to QuantLib::Bond::Price::Type. More...
 
boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod (const string &s)
 Convert text to QuantLib::Period or QuantLib::Date. More...
 
void parseDateOrPeriod (const string &s, QuantLib::Date &d, QuantLib::Period &p, bool &isDate)
 Convert text to QuantLib::Period or QuantLib::Date (deprecated version) More...
 
QuantLib::LsmBasisSystem::PolynomialType parsePolynomType (const std::string &s)
 Convert text to QuantLib::LsmBasisSystem::PolynomialType. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::LsmBasisSystem::PolynomialType a)
 Write QuantLib::LsmBasisSystem::PolynomialType to stream. More...
 
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering (const std::string &s)
 Convert text to QuantLib::SobolBrownianGenerator::Ordering. More...
 
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers (const std::string &s)
 Convert text to QuantLib::SobolRsg::DirectionIntegers. More...
 
Weekday parseWeekday (const string &s)
 
Month parseMonth (const string &s)
 
PaymentLag parsePaymentLag (const string &s)
 Convert text to PaymentLag. More...
 
template<class T >
std::vector< T > parseListOfValues (string s, std::function< T(string)> parser)
 Convert comma separated list of values to vector of values. More...
 
SequenceType parseSequenceType (const std::string &s)
 Convert string to sequence type. More...
 
QuantLib::CPI::InterpolationType parseObservationInterpolation (const std::string &s)
 Convert string to observation interpolation. More...
 
FdmSchemeDesc parseFdmSchemeDesc (const std::string &s)
 Convert string to fdm scheme desc. More...
 
AssetClass parseAssetClass (const std::string &s)
 Convert text to ore::data::AssetClass. More...
 
std::ostream & operator<< (std::ostream &os, AssetClass a)
 Write ore::data::AssetClass to stream. More...
 
DeltaVolQuote::AtmType parseAtmType (const std::string &s)
 Convert text to QuantLib::DeltaVolQuote::AtmType. More...
 
DeltaVolQuote::DeltaType parseDeltaType (const std::string &s)
 Convert text to QuantLib::DeltaVolQuote::DeltaType. More...
 
QuantLib::Rounding::Type parseRoundingType (const std::string &s)
 Convert text to QuantLib::Rounding. More...
 
Barrier::Type parseBarrierType (const string &s)
 Convert std::string to QuantLib::BarrierType. More...
 
DoubleBarrier::Type parseDoubleBarrierType (const string &s)
 Convert std::string to QuantLib::DoubleBarrierType. More...
 
template<class T >
bool tryParse (const std::string &str, T &obj, std::function< T(const std::string &)> parser)
 
VolatilityType parseVolatilityQuoteType (const string &s)
 
CapFloor::Type parseCapFloorType (const string &s)
 
YoYInflationCapFloor::Type parseYoYInflationCapFloorType (const string &s)
 
QuantExt::CrossAssetModel::AssetType parseCamAssetType (const string &s)
 
pair< string, string > parseBoostAny (const boost::any &anyType, Size precision)
 
CdsOption::StrikeType parseCdsOptionStrikeType (const string &s)
 
Average::Type parseAverageType (const std::string &s)
 
QuantExt::BondIndex::PriceQuoteMethod parsePriceQuoteMethod (const std::string &s)
 
string fxDominance (const string &s1, const string &s2)
 Convert FX pair to market standard dominance. More...
 
MomentType parseMomentType (const std::string &s)
 Convert text to ore::data::MomentType. More...
 
QuantLib::Pillar::Choice parsePillarChoice (const std::string &s)
 Convert text to QuantLib::Pillar::Choice. More...
 
QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel (const std::string &s)
 Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel. More...
 
MporCashFlowMode parseMporCashFlowMode (const std::string &s)
 Convert text to MporCashFlowMode. More...
 
std::ostream & operator<< (std::ostream &os, MporCashFlowMode t)
 Write MporCashFlowMode to stream. More...
 
SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant (const std::string &s)
 Parse SabrParametricVolatility::ModelVariant. More...
 
std::ostream & operator<< (std::ostream &out, QuantExt::SabrParametricVolatility::ModelVariant m)
 Write SabrParametricVolatility::ModelVariant. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::Exercise::Type type)
 Write QuantLib::Exercise::Type. More...
 
template<class Archive >
void serialize (Archive &ar, QuantLib::Date &d, const unsigned int)
 Allow for serialization of QuantLib::Date without amending its class (non-intrusive) More...
 
template<class Archive >
void serialize (Archive &ar, QuantLib::DayCounter &dc, const unsigned int)
 Allow for serialization of QuantLib::Period without amending its class (non-intrusive) More...
 
template<class Archive >
void serialize (Archive &ar, QuantLib::Period &p, const unsigned int)
 Allow for serialization of QuantLib::Period without amending its class (non-intrusive) More...
 
Strike parseStrike (const std::string &s)
 Convert text to Strike. More...
 
std::ostream & operator<< (std::ostream &out, const Strike &s)
 Convert Strike to text. More...
 
bool operator== (const Strike &s1, const Strike &s2)
 Logical comparison of strikes. More...
 
QuantLib::Real computeAbsoluteStrike (const Strike &s, const QuantLib::Real atm, const QuantLib::Real atmf)
 Convenience function that computes an absolute strike. More...
 
std::string to_string (const QuantLib::Date &date)
 Convert QuantLib::Date to std::string. More...
 
string to_string (bool aBool)
 Convert bool to std::string. More...
 
std::string to_string (const QuantLib::Period &period)
 Convert QuantLib::Period to std::string. More...
 
template<class T >
std::string to_string (const std::vector< T > &vec, const std::string &sep=",")
 Convert vector to std::string. More...
 
template<class T >
std::string to_string (const std::set< T > &set, const std::string &sep=",")
 Convert set to std::string. More...
 
template<class T >
std::string to_string (const T &t)
 Convert type to std::string. More...
 
template<typename T , typename Compare >
std::vector< std::size_t > sort_permutation (const std::vector< T > &vec, Compare &compare)
 
template<typename T >
std::vector< T > apply_permutation (const std::vector< T > &vec, const std::vector< std::size_t > &p)
 
template<typename T >
void apply_permutation_in_place (std::vector< T > &vec, const std::vector< std::size_t > &p)
 

Detailed Description

Grouping of all utility related classes, functions and files

Reference: http://stackoverflow.com/questions/17074324/how-can-i-sort-two-vectors-in-the-same-way-with-criteria-that-uses-only-one-of

Function Documentation

◆ tryParseCdsInformation()

bool tryParseCdsInformation ( std::string  strInfo,
CdsReferenceInformation cdsInfo 
)

Attempt to parse string to CdsReferenceInformation

Parameters
[in]strInfoThe string we wish to convert to CdsReferenceInformation
[out]cdsInfoThe resulting CdsReferenceInformation if the parsing was successful.
Returns
true if the parsing was successful and false if not.

If the function receives a strInfo of the form ID|TIER|CCY|DOCCLAUSE with CCY being a valid ISO currency code, TIER being a valid CDS debt tier and DOCCLAUSE being a valid CDS documentation clause, the parsing should be successful. Here, DOCCLAUSE is optional.

Definition at line 449 of file creditdefaultswapdata.cpp.

449 {
450
451 DLOG("tryParseCdsInformation: attempting to parse " << strInfo);
452
453 // As in documentation comment, expect strInfo of form ID|TIER|CCY(|DOCCLAUSE)
454 vector<string> tokens;
455 boost::split(tokens, strInfo, boost::is_any_of("|"));
456
457 if (tokens.size() != 4 && tokens.size() != 3) {
458 TLOG("String " << strInfo << " not of form ID|TIER|CCY(|DOCCLAUSE) so parsing failed");
459 return false;
460 }
461
462 CdsTier cdsTier;
463 if (!tryParse<CdsTier>(tokens[1], cdsTier, &parseCdsTier)) {
464 return false;
465 }
466
467 Currency ccy;
468 if (!tryParseCurrency(tokens[2], ccy)) {
469 return false;
470 }
471
472 boost::optional<CdsDocClause> cdsDocClause;
473 if (tokens.size() == 4) {
474 CdsDocClause tmp;
475 if (!tryParse<CdsDocClause>(tokens[3], tmp, &parseCdsDocClause)) {
476 return false;
477 }
478 cdsDocClause = tmp;
479 }
480
481 cdsInfo = CdsReferenceInformation(tokens[0], cdsTier, ccy, cdsDocClause);
482
483 return true;
484}
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
#define TLOG(text)
Logging Macro (Level = Data)
Definition: log.hpp:556
CdsDocClause
CDS documentation clause enumeration.
CdsTier
CDS debt tier enumeration.
bool tryParseCurrency(const std::string &str, Currency &obj)
Definition: parsers.hpp:438
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flowAnalysis()

std::vector< std::vector< std::string > > flowAnalysis ( const QuantLib::Leg &  leg)

Flow Analysis.

Definition at line 158 of file flowanalysis.cpp.

158 {
159 AnalysisGenerator generator;
160 for (QuantLib::Size i = 0; i < leg.size(); ++i)
161 leg[i]->accept(generator);
162 return generator.analysis();
163}
Matrix generator(const Matrix &t, const Real horizon)
+ Here is the call graph for this function:

◆ parseFxIndex()

QuantLib::ext::shared_ptr< QuantExt::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.

Definition at line 208 of file indexparser.cpp.

210 {
211 std::vector<string> tokens;
212 split(tokens, s, boost::is_any_of("-"));
213 QL_REQUIRE(tokens.size() == 4, "four tokens required in " << s << ": FX-TAG-CCY1-CCY2");
214 QL_REQUIRE(tokens[0] == "FX", "expected first token to be FX");
215 Natural fixingDays = 0;
216 Calendar fixingCalendar = NullCalendar();
217 BusinessDayConvention bdc;
218 if (useConventions)
219 std::tie(fixingDays, fixingCalendar, bdc) = getFxIndexConventions(s);
220 auto index = QuantLib::ext::make_shared<FxIndex>(tokens[1], fixingDays, parseCurrency(tokens[2]), parseCurrency(tokens[3]),
221 fixingCalendar, fxSpot, sourceYts, targetYts);
222
223 IndexNameTranslator::instance().add(index->name(), s);
224 return index;
225}
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
std::tuple< Natural, Calendar, BusinessDayConvention > getFxIndexConventions(const string &index)
Definition: marketdata.cpp:160
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseIborIndex() [1/2]

QuantLib::ext::shared_ptr< IborIndex > parseIborIndex ( const string &  s,
const Handle< YieldTermStructure > &  h 
)

Convert std::string to QuantLib::IborIndex.

Definition at line 254 of file indexparser.cpp.

254 {
255 string dummy;
256 return parseIborIndex(s, dummy, h);
257}
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
Convert std::string to QuantLib::IborIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseIborIndex() [2/2]

QuantLib::ext::shared_ptr< IborIndex > parseIborIndex ( const std::string &  strIndex,
std::string &  outTenor,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  h = QuantLib::Handle< QuantLib::YieldTermStructure >() 
)

Convert std::string to QuantLib::IborIndex and return the tenor string component of the index.

In some cases, after parsing the IborIndex, we would like to know the exact tenor string that was part of the strIndex that was parsed. If we ask the resulting index for its tenor via the method Period InterestRateIndex::tenor(), it can be difficult to deduce the original tenor string. A simple example of this is MXN-TIIE-28D where if you call tenor() and then to_string(), you get 4W which is different than the original 28D that is passed in.

Warning:
If the strIndex does not have a tenor component, as is the usual case for overnight indices, outTenor will be populated with the empty string.

◆ tryParseIborIndex()

bool tryParseIborIndex ( const string &  s,
QuantLib::ext::shared_ptr< IborIndex > &  index 
)

Try to convert std::string to QuantLib::IborIndex.

Definition at line 244 of file indexparser.cpp.

244 {
245 try {
246 index = parseIborIndex(s, Handle<YieldTermStructure>());
247 } catch (const std::exception& e) {
248 DLOG("tryParseIborIndex(" << s << ") failed: " << e.what());
249 return false;
250 }
251 return true;
252}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isGenericIborIndex()

bool isGenericIborIndex ( const string &  indexName)

Return true if the indexName is that of a generic ibor index, otherwise false.

Definition at line 442 of file indexparser.cpp.

442{ return indexName.find("-GENERIC-") != string::npos; }
+ Here is the caller graph for this function:

◆ isInflationIndex()

std::pair< bool, QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > > isInflationIndex ( const std::string &  indexName)

Returns true as the first element in the pair if the indexName is that of an InflationIndex. The second element in the pair is an instance of the inflation index. If indexName is not an inflation index, the first element in the pair is false and the second element is a nullptr.

If inflation indices have been set up via ZeroInflationIndex entries in the Conventions, the conventions should be passed here. If not, the default nullptr parameter will be sufficient.

Definition at line 444 of file indexparser.cpp.

444 {
445
446 QuantLib::ext::shared_ptr<ZeroInflationIndex> index;
447 try {
448 // Currently, only way to have an inflation index is to have a ZeroInflationIndex
449 index = parseZeroInflationIndex(indexName, Handle<ZeroInflationTermStructure>());
450 } catch (...) {
451 return make_pair(false, nullptr);
452 }
453 return make_pair(true, index);
454}
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex(const string &s, const Handle< ZeroInflationTermStructure > &h)
Convert std::string to QuantLib::ZeroInflationIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEquityIndex()

bool isEquityIndex ( const string &  indexName)

Return true if the indexName is that of an EquityIndex, otherwise false.

Definition at line 456 of file indexparser.cpp.

456 {
457 try {
458 parseEquityIndex(indexName);
459 } catch (...) {
460 return false;
461 }
462 return true;
463}
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > parseEquityIndex(const string &s)
Convert std::string (e.g SP5) to QuantExt::EquityIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCommodityIndex()

bool isCommodityIndex ( const string &  indexName)

Return true if the indexName is that of an CommodityIndex, otherwise false.

Definition at line 465 of file indexparser.cpp.

465 {
466 try {
467 parseCommodityIndex(indexName);
468 } catch (...) {
469 return false;
470 }
471 return true;
472}
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseCommodityIndex(const string &name, bool hasPrefix, const Handle< PriceTermStructure > &ts, const Calendar &cal, const bool enforceFutureIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isGenericIndex()

bool isGenericIndex ( const std::string &  indexName)

Return true if the indexName is that of an GenericIndex, otherwise false

Definition at line 474 of file indexparser.cpp.

474 {
475 try {
476 parseGenericIndex(indexName);
477 }
478 catch (...) {
479 return false;
480 }
481 return true;
482}
QuantLib::ext::shared_ptr< QuantLib::Index > parseGenericIndex(const string &s)
Convert std::string (GENERIC-...) to QuantExt::Index.
+ Here is the call graph for this function:

◆ parseEquityIndex()

QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > parseEquityIndex ( const string &  s)

Convert std::string (e.g SP5) to QuantExt::EquityIndex.

Definition at line 227 of file indexparser.cpp.

227 {
228 std::vector<string> tokens;
229 split(tokens, s, boost::is_any_of("-"));
230 QL_REQUIRE(tokens.size() == 2, "two tokens required in " << s << ": EQ-NAME");
231 QL_REQUIRE(tokens[0] == "EQ", "expected first token to be EQ");
232 auto index = QuantLib::ext::make_shared<QuantExt::EquityIndex2>(tokens[1], NullCalendar(), Currency());
233 IndexNameTranslator::instance().add(index->name(), s);
234 return index;
235}
+ Here is the caller graph for this function:

◆ parseSwapIndex()

QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex ( const string &  s,
const Handle< YieldTermStructure > &  f,
const Handle< YieldTermStructure > &  d 
)

Convert std::string to QuantLib::SwapIndex.

Definition at line 501 of file indexparser.cpp.

502 {
503
504 std::vector<string> tokens;
505 split(tokens, s, boost::is_any_of("-"));
506 QL_REQUIRE(tokens.size() == 3 || tokens.size() == 4,
507 "three or four tokens required in " << s << ": CCY-CMS-TENOR or CCY-CMS-TAG-TENOR");
508 QL_REQUIRE(tokens[0].size() == 3, "invalid currency code in " << s);
509 QL_REQUIRE(tokens[1] == "CMS", "expected CMS as middle token in " << s);
510 Period p = parsePeriod(tokens.back());
511 // use default family name, if none is given
512 string familyName = tokens.size() == 4 ? tokens[0] + "-CMS-" + tokens[2] : tokens[0] + "LiborSwapIsdaFix";
513 Currency ccy = parseCurrency(tokens[0]);
514
515 const QuantLib::ext::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
516 QuantLib::ext::shared_ptr<SwapIndexConvention> swapIndexConvention;
517 QuantLib::ext::shared_ptr<IRSwapConvention> irSwapConvention;
518 QuantLib::ext::shared_ptr<OisConvention> oisCompConvention;
519 QuantLib::ext::shared_ptr<AverageOisConvention> oisAvgConvention;
520 if (conventions && conventions->has(s, Convention::Type::SwapIndex)) {
521 swapIndexConvention = QuantLib::ext::dynamic_pointer_cast<SwapIndexConvention>(conventions->get(s));
522 QL_REQUIRE(swapIndexConvention, "internal error: could not cast to SwapIndexConvention");
523 QL_REQUIRE(conventions->has(swapIndexConvention->conventions(), Convention::Type::Swap) ||
524 conventions->has(swapIndexConvention->conventions(), Convention::Type::OIS) ||
525 conventions->has(swapIndexConvention->conventions(), Convention::Type::AverageOIS),
526 "do not have swap or ois conventions for '"
527 << swapIndexConvention->conventions() << "', required from swap index convention '" << s << "'");
528 irSwapConvention =
529 QuantLib::ext::dynamic_pointer_cast<IRSwapConvention>(conventions->get(swapIndexConvention->conventions()));
530 oisCompConvention =
531 QuantLib::ext::dynamic_pointer_cast<OisConvention>(conventions->get(swapIndexConvention->conventions()));
532 oisAvgConvention =
533 QuantLib::ext::dynamic_pointer_cast<AverageOisConvention>(conventions->get(swapIndexConvention->conventions()));
534 QL_REQUIRE(irSwapConvention || oisCompConvention || oisAvgConvention,
535 "internal error: could not cast to IRSwapConvention, OisConvention, AverageOisConvention");
536 } else {
537 // set default conventions using a generic ibor index
538 irSwapConvention = QuantLib::ext::make_shared<IRSwapConvention>("dummy_swap_conv_" + tokens[0], tokens[0], "Annual",
539 "MF", "A365", tokens[0] + "-GENERIC-3M");
540 swapIndexConvention = QuantLib::ext::make_shared<SwapIndexConvention>("dummy_swapindex_conv_" + tokens[0],
541 "dummy_swap_conv_" + tokens[0], "");
542 }
543
544 QuantLib::ext::shared_ptr<SwapIndex> index;
545 if (irSwapConvention) {
546 Calendar fixingCalendar = swapIndexConvention->fixingCalendar().empty()
547 ? irSwapConvention->fixedCalendar()
548 : parseCalendar(swapIndexConvention->fixingCalendar());
549 index = QuantLib::ext::make_shared<SwapIndex>(familyName, p, irSwapConvention->index()->fixingDays(), ccy,
550 fixingCalendar, Period(irSwapConvention->fixedFrequency()),
551 irSwapConvention->fixedConvention(), irSwapConvention->fixedDayCounter(),
552 irSwapConvention->index()->clone(f), d);
553 } else if (oisCompConvention) {
554 Calendar fixingCalendar = swapIndexConvention->fixingCalendar().empty()
555 ? oisCompConvention->index()->fixingCalendar()
556 : parseCalendar(swapIndexConvention->fixingCalendar());
557 index = QuantLib::ext::make_shared<OvernightIndexedSwapIndex>(
558 familyName, p, oisCompConvention->spotLag(), ccy,
559 QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(oisCompConvention->index()->clone(f)), true,
560 RateAveraging::Compound, Period(oisCompConvention->fixedFrequency()), d);
561 } else if (oisAvgConvention) {
562 Calendar fixingCalendar = swapIndexConvention->fixingCalendar().empty()
563 ? oisAvgConvention->index()->fixingCalendar()
564 : parseCalendar(swapIndexConvention->fixingCalendar());
565 auto index = QuantLib::ext::make_shared<OvernightIndexedSwapIndex>(
566 familyName, p, oisAvgConvention->spotLag(), ccy,
567 QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(oisAvgConvention->index()->clone(f)), true,
568 RateAveraging::Simple, Period(oisAvgConvention->fixedFrequency()), d);
569 IndexNameTranslator::instance().add(index->name(), s);
570 return index;
571 } else {
572 QL_FAIL("internal error: expected irSwapConvention, oisConvention, averageOisConvention to be not null");
573 }
574 IndexNameTranslator::instance().add(index->name(), s);
575 return index;
576}
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
Size size(const ValueType &v)
Definition: value.cpp:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseZeroInflationIndex()

QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex ( const string &  s,
const Handle< ZeroInflationTermStructure > &  h 
)

Convert std::string to QuantLib::ZeroInflationIndex.

Definition at line 616 of file indexparser.cpp.

617 {
618 const QuantLib::ext::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
619
620 // If conventions are non-null and we have provided a convention of type InflationIndex with a name equal to the
621 // string s, we use that convention to construct the inflation index.
622 if (conventions) {
623 pair<bool, QuantLib::ext::shared_ptr<Convention>> p = conventions->get(s, Convention::Type::ZeroInflationIndex);
624 if (p.first) {
625 auto c = QuantLib::ext::dynamic_pointer_cast<ZeroInflationIndexConvention>(p.second);
626 auto index = QuantLib::ext::make_shared<ZeroInflationIndex>(s, c->region(), c->revised(),
627 c->frequency(), c->availabilityLag(), c->currency(), h);
628 IndexNameTranslator::instance().add(index->name(), s);
629 return index;
630 }
631 }
632
633 static map<string, QuantLib::ext::shared_ptr<ZeroInflationIndexParserBase>> m = {
634 {"AUCPI", QuantLib::ext::make_shared<ZeroInflationIndexParserWithFrequency<AUCPI>>(Quarterly)},
635 {"AU CPI", QuantLib::ext::make_shared<ZeroInflationIndexParserWithFrequency<AUCPI>>(Quarterly)},
636 {"BEHICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<BEHICP>>()},
637 {"BE HICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<BEHICP>>()},
638 {"EUHICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICP>>()},
639 {"EU HICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICP>>()},
640 {"EUHICPXT", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICPXT>>()},
641 {"EU HICPXT", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICPXT>>()},
642 {"FRHICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRHICP>>()},
643 {"FR HICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRHICP>>()},
644 {"FRCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRCPI>>()},
645 {"FR CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRCPI>>()},
646 {"UKRPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<UKRPI>>()},
647 {"UK RPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<UKRPI>>()},
648 {"USCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<USCPI>>()},
649 {"US CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<USCPI>>()},
650 {"ZACPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<ZACPI>>()},
651 {"ZA CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<ZACPI>>()},
652 {"SECPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<SECPI>>()},
653 {"DKCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<DKCPI>>()},
654 {"CACPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<CACPI>>()},
655 {"ESCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<ESCPI>>()},
656 {"DECPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<DECPI>>()},
657 {"DE CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<DECPI>>()}};
658
659 auto it = m.find(s);
660 if (it != m.end()) {
661 auto index = it->second->build(h);
662 IndexNameTranslator::instance().add(index->name(), s);
663 return index;
664 } else {
665 QL_FAIL("parseZeroInflationIndex: \"" << s << "\" not recognized");
666 }
667}
+ Here is the caller graph for this function:

◆ parseBondIndex()

QuantLib::ext::shared_ptr< QuantExt::BondIndex > parseBondIndex ( const string &  name)

Convert std::string to QuantExt::BondIndex.

Definition at line 728 of file indexparser.cpp.

728 {
729
730 // Make sure the prefix is correct
731 string prefix = name.substr(0, 5);
732 QL_REQUIRE(prefix == "BOND-", "A bond index string must start with 'BOND-' but got " << prefix);
733
734 // Now take the remainder of the string
735 // for spot indices, this should just be the bond name
736 // for future indices, this is of the form NAME-YYYY-MM or NAME-YYYY-MM-DD where NAME is the commodity name
737 // (possibly containing hyphens) and YYYY-MM(-DD) is the expiry date of the futures contract
738 Date expiry;
739 string nameWoPrefix = name.substr(5);
740 string bondName = nameWoPrefix;
741
742 // Check for form NAME-YYYY-MM-DD
743 if (nameWoPrefix.size() > 10) {
744 string test = nameWoPrefix.substr(nameWoPrefix.size() - 10);
745 if (boost::regex_match(test, boost::regex("\\d{4}-\\d{2}-\\d{2}"))) {
746 expiry = parseDate(test);
747 bondName = nameWoPrefix.substr(0, nameWoPrefix.size() - test.size() - 1);
748 }
749 }
750
751 // Check for form NAME-YYYY-MM if NAME-YYYY-MM-DD failed
752 if (expiry == Date() && nameWoPrefix.size() > 7) {
753 string test = nameWoPrefix.substr(nameWoPrefix.size() - 7);
754 if (boost::regex_match(test, boost::regex("\\d{4}-\\d{2}"))) {
755 expiry = parseDate(test + "-01");
756 bondName = nameWoPrefix.substr(0, nameWoPrefix.size() - test.size() - 1);
757 }
758 }
759
760 // Create and return the required future index
761 QuantLib::ext::shared_ptr<BondIndex> index;
762 if (expiry != Date()) {
763 index= QuantLib::ext::make_shared<BondFuturesIndex>(expiry, bondName);
764 } else {
765 index= QuantLib::ext::make_shared<BondIndex>(bondName);
766 }
767 IndexNameTranslator::instance().add(index->name(), name);
768 return index;
769}
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
string name
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseConstantMaturityBondIndex()

QuantLib::ext::shared_ptr< QuantExt::ConstantMaturityBondIndex > parseConstantMaturityBondIndex ( const string &  name)

Convert std::string to QuantExt::ConstantMaturityBondIndex.

Definition at line 771 of file indexparser.cpp.

771 {
772 // Expected bondId structure with at least three tokens, separated by "-", of the form CMB-FAMILY-TERM, for example:
773 // CMB-US-CMT-5Y, CMB-US-TIPS-10Y, CMB-UK-GILT-5Y, CMB-DE-BUND-10Y
774 // with two tokens in the middle to define the family
775 std::vector<string> tokens;
776 split(tokens, name, boost::is_any_of("-"));
777 QL_REQUIRE(tokens.size() >= 3, "Generic Bond ID with at least two tokens separated by - expected, found " << name);
778
779 // Make sure the prefix is correct
780 std::string prefix = tokens[0];
781 QL_REQUIRE(prefix == "CMB", "A constant maturity bond yield index string must start with 'CMB' but got " << prefix);
782
783 std::string securityFamily = tokens[1];
784 for (Size i = 2; i < tokens.size() - 1; ++i)
785 securityFamily = securityFamily + "-" + tokens[i];
786 Period underlyingPeriod = parsePeriod(tokens.back());
787 QuantLib::ext::shared_ptr<ConstantMaturityBondIndex> i;
788 try {
789 i = QuantLib::ext::make_shared<ConstantMaturityBondIndex>(prefix + "-" + securityFamily, underlyingPeriod);
790 } catch(std::exception& e) {
791 ALOG("error creating CMB index: " << e.what());
792 }
793 IndexNameTranslator::instance().add(i->name(), name);
794 return i;
795}
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseCommodityIndex()

QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseCommodityIndex ( const std::string &  name,
bool  hasPrefix = true,
const QuantLib::Handle< QuantExt::PriceTermStructure > &  ts = QuantLib::Handle< QuantExt::PriceTermStructure >(),
const QuantLib::Calendar &  cal = QuantLib::NullCalendar(),
const bool  enforceFutureIndex = true 
)

Convert std::string to QuantExt::ComodityIndex

This function can be used to parse commodity spot indices or commodity future indices:

  • for spot indices, the name is of the form COMM-EXCHANGE:COMMODITY
  • for future indices, the name is of the form COMM-EXCHANGE:CONTRACT:YYYY-MM or COMM-EXCHANGE:CONTRACT:YYYY-MM-DD

◆ parseGenericIndex()

QuantLib::ext::shared_ptr< QuantLib::Index > parseGenericIndex ( const string &  s)

Convert std::string (GENERIC-...) to QuantExt::Index.

Definition at line 237 of file indexparser.cpp.

237 {
238 QL_REQUIRE(boost::starts_with(s, "GENERIC-"), "generic index expected to be of the form GENERIC-*");
239 auto index = QuantLib::ext::make_shared<GenericIndex>(s);
240 IndexNameTranslator::instance().add(index->name(), s);
241 return index;
242}
+ Here is the caller graph for this function:

◆ parseIndex()

QuantLib::ext::shared_ptr< Index > parseIndex ( const string &  s)

Convert std::string to QuantLib::Index.

Definition at line 909 of file indexparser.cpp.

909 {
910 QuantLib::ext::shared_ptr<QuantLib::Index> ret_idx;
911 try {
912 ret_idx = parseEquityIndex(s);
913 } catch (...) {
914 }
915 if (!ret_idx) {
916 try {
917 ret_idx = parseBondIndex(s);
918 } catch (...) {
919 }
920 }
921 if (!ret_idx) {
922 try {
923 ret_idx = parseCommodityIndex(s, true, QuantLib::Handle<QuantExt::PriceTermStructure>(), QuantLib::NullCalendar(), false);
924 } catch (...) {
925 }
926 }
927 if (!ret_idx) {
928 try {
929 ret_idx = parseFxIndex(s);
930 } catch (...) {
931 }
932 }
933 if (!ret_idx) {
934 try {
935 ret_idx = parseGenericIndex(s);
936 } catch (...) {
937 }
938 }
939 if (!ret_idx) {
940 try {
942 } catch (...) {
943 }
944 }
945 if (!ret_idx) {
946 try {
947 ret_idx = parseIborIndex(s);
948 } catch (...) {
949 }
950 }
951 if (!ret_idx) {
952 try {
953 ret_idx = parseSwapIndex(s, Handle<YieldTermStructure>(), Handle<YieldTermStructure>());
954 } catch (...) {
955 }
956 }
957 if (!ret_idx) {
958 try {
959 ret_idx = parseZeroInflationIndex(s, Handle<ZeroInflationTermStructure>());
960 } catch (...) {
961 }
962 }
963 QL_REQUIRE(ret_idx, "parseIndex \"" << s << "\" not recognized");
964 return ret_idx;
965}
QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex(const string &s, const Handle< YieldTermStructure > &f, const Handle< YieldTermStructure > &d)
Convert std::string to QuantLib::SwapIndex.
QuantLib::ext::shared_ptr< 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.
QuantLib::ext::shared_ptr< BondIndex > parseBondIndex(const string &name)
Convert std::string to QuantExt::BondIndex.
QuantLib::ext::shared_ptr< ConstantMaturityBondIndex > parseConstantMaturityBondIndex(const string &name)
Convert std::string to QuantExt::ConstantMaturityBondIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isOvernightIndex()

bool isOvernightIndex ( const string &  indexName)

Return true if the indexName is that of an overnight index, otherwise false.

Definition at line 967 of file indexparser.cpp.

967 {
968
969 QuantLib::ext::shared_ptr<IborIndex> index;
970 if (tryParseIborIndex(indexName, index)) {
971 auto onIndex = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(index);
972 if (onIndex)
973 return true;
974 }
975
976 return false;
977}
bool tryParseIborIndex(const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
Try to convert std::string to QuantLib::IborIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBmaIndex()

bool isBmaIndex ( const string &  indexName)

Return true if the indexName is that of an bma/sifma index, otherwise false.

Definition at line 979 of file indexparser.cpp.

979 {
980 QuantLib::ext::shared_ptr<IborIndex> index;
981 if (tryParseIborIndex(indexName, index)) {
982 // in ore a bma index is parsed to a BMAIndexWrapper instance!
983 return QuantLib::ext::dynamic_pointer_cast<BMAIndexWrapper>(index) != nullptr;
984 }
985 return false;
986}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ internalIndexName()

std::string internalIndexName ( const std::string &  indexName)

In some cases, we allow multiple external ibor index names to represent the same QuantLib index. This function returns the unique index name that we use internally to represent the QuantLib index.

For example, we allow:

  • USD-FedFunds-1D and USD-FedFunds externally but we use USD-FedFunds internally
  • CAD-BA-tenor and CAD-CDOR-tenor externally but we use CAD-CDOR-tenor internally

Definition at line 988 of file indexparser.cpp.

988 {
989
990 // Check that the indexName string is of the required form
991 vector<string> tokens;
992 split(tokens, indexName, boost::is_any_of("-"));
993 QL_REQUIRE(tokens.size() == 2 || tokens.size() == 3,
994 "Two or three tokens required in " << indexName << ": CCY-INDEX or CCY-INDEX-TERM");
995
996 // Static map of allowable alternative external names to our unique internal name
997 static map<string, string> m = {{"DKK-TNR", "DKK-DKKOIS"}, {"EUR-EURIB", "EUR-EURIBOR"}, {"CAD-BA", "CAD-CDOR"},
998 {"EUR-ESTR", "EUR-ESTER"}, {"EUR-STR", "EUR-ESTER"}, {"JPY-TONA", "JPY-TONAR"},
999 {"JPY-TORF", "JPY-TONAR"}};
1000
1001 // Is start of indexName covered by the map? If so, update it.
1002 string tmpName = tokens[0] + "-" + tokens[1];
1003 if (m.count(tmpName) == 1) {
1004 tmpName = m.at(tmpName);
1005 }
1006
1007 // If there were only two tokens, return the possibly updated two tokens.
1008 if (tokens.size() == 2) {
1009 return tmpName;
1010 }
1011
1012 // Check if we have an overnight index
1013 // This covers cases like USD-FedFunds-1D and returns USD-FedFunds
1014 // (no need to check convention based overnight indices, they are always of the form CCY-INDEX)
1015 if (parsePeriod(tokens[2]) == 1 * Days && isOvernightIndex(tmpName)) {
1016 return tmpName;
1017 }
1018
1019 // Allow USD-SIFMA-1W or USD-SIFMA-7D externally. USD-SIFMA is used internally.
1020 if (tmpName == "USD-SIFMA" && (tokens[2] == "1W" || tokens[2] == "7D")) {
1021 return tmpName;
1022 }
1023
1024 return tmpName + "-" + tokens[2];
1025}
bool isOvernightIndex(const string &indexName)
Return true if the indexName is that of an overnight index, otherwise false.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOsName()

std::string getOsName ( )

Returns the OS Name.

Definition at line 284 of file osutils.cpp.

284 {
285#if defined(__unix) || defined(__unix__)
286 return "Unix";
287#elif __linux__
288 return "Linux";
289#elif __FreeBSD__
290 return "FreeBSD";
291#else
292 return "Other";
293#endif
294}
+ Here is the caller graph for this function:

◆ getOsVersion()

std::string getOsVersion ( )

Returns the OS Version.

Definition at line 296 of file osutils.cpp.

296 {
297 struct utsname unameData;
298 if (uname(&unameData))
299 return "?"; // error
300 else
301 return unameData.release;
302}
+ Here is the caller graph for this function:

◆ getCpuName()

std::string getCpuName ( )

Returns the CPU name (e.g. "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz".

Definition at line 327 of file osutils.cpp.

327{ return parseProcFile("/proc/cpuinfo", "model name"); }
+ Here is the caller graph for this function:

◆ getNumberCores()

unsigned int getNumberCores ( )

Returns the number of Cores available to the OS.

Definition at line 329 of file osutils.cpp.

329 {
330 long n = sysconf(_SC_NPROCESSORS_ONLN);
331 if (n < 0) // error
332 return 0;
333 else
334 return n;
335}
+ Here is the caller graph for this function:

◆ getMemoryRAM()

std::string getMemoryRAM ( )

Returns the total amount of memory available (installed RAM)

Definition at line 350 of file osutils.cpp.

350{ return parseProcFile("/proc/meminfo", "MemTotal"); }
+ Here is the caller graph for this function:

◆ getMemoryUsage()

std::string getMemoryUsage ( )

Returns the current process memory usage.

Definition at line 99 of file osutils.cpp.

99{ return memoryString(getMemoryUsageBytes()); }
unsigned long long getMemoryUsageBytes()
Definition: osutils.cpp:337
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPeakMemoryUsage()

std::string getPeakMemoryUsage ( )

Returns the current process peak memory usage.

Definition at line 101 of file osutils.cpp.

101{ return memoryString(getPeakMemoryUsageBytes()); }
unsigned long long getPeakMemoryUsageBytes()
Returns the current process peak memory usage in bytes.
Definition: osutils.cpp:207
+ Here is the call graph for this function:

◆ getMemoryUsageBytes()

unsigned long long getMemoryUsageBytes ( )

Returns the current process memory usage in bytes Parts of code taken from: http://nadeausoftware.com/articles/2012/07/c_c_tip_how_get_process_resident_set_size_physical_memory_use

Definition at line 337 of file osutils.cpp.

337 {
338 unsigned long long rss = 0ULL;
339 FILE* fp = NULL;
340 if ((fp = fopen("/proc/self/statm", "r")) == NULL)
341 return 0ULL; /* Can't open? */
342 if (fscanf(fp, "%*s%llu", &rss) != 1) {
343 fclose(fp);
344 return 0ULL; /* Can't read? */
345 }
346 fclose(fp);
347 return (unsigned long long)rss * (unsigned long long)sysconf(_SC_PAGESIZE);
348}
+ Here is the caller graph for this function:

◆ getPeakMemoryUsageBytes()

unsigned long long getPeakMemoryUsageBytes ( )

Returns the current process peak memory usage in bytes.

Definition at line 207 of file osutils.cpp.

207 {
208 rusage ru;
209 getrusage(RUSAGE_SELF, &ru);
210#if defined __APPLE__
211 return (size_t)ru.ru_maxrss;
212#else
213 return (size_t)(ru.ru_maxrss * 1024L);
214#endif
215}
+ Here is the caller graph for this function:

◆ getUsername()

std::string getUsername ( )

Returns the current username.

Definition at line 217 of file osutils.cpp.

217 {
218 char* login = getlogin();
219#ifdef __linux__
220 if (!login)
221 login = cuserid(NULL);
222#endif
223 return login;
224}
+ Here is the caller graph for this function:

◆ getHostname()

std::string getHostname ( )

Returns the machine name.

Definition at line 226 of file osutils.cpp.

226 {
227 char buf[100];
228 size_t buflen = 100;
229 gethostname(buf, buflen);
230 buf[buflen - 1] = '\0';
231 return buf;
232}
+ Here is the caller graph for this function:

◆ getSystemDetails()

std::string getSystemDetails ( )

Returns all the above system details in a single string.

Definition at line 82 of file osutils.cpp.

82 {
83 ostringstream oss;
84 oss << "System Details:" << endl;
85 oss << " OS : " << os::getOsName() << endl;
86 oss << " OS Version : " << os::getOsVersion() << endl;
87 oss << " CPU : " << os::getCpuName() << endl;
88 oss << " Cores : " << os::getNumberCores() << endl;
89 oss << " Memory (Available) : " << os::getMemoryRAM() << endl;
90 oss << " Memory (Process) : " << os::getMemoryUsage() << endl;
91 oss << " Hostname : " << os::getHostname() << endl;
92 oss << " Username : " << os::getUsername() << endl;
93 oss << " ORE Version : " << OPEN_SOURCE_RISK_VERSION << endl;
94 oss << " QuantLib Version : " << QL_VERSION << endl;
95 oss << " Boost Version : " << BOOST_LIB_VERSION << endl;
96 return oss.str();
97}
#define OPEN_SOURCE_RISK_VERSION
+ Here is the call graph for this function:

◆ dumpStacktrace()

void dumpStacktrace ( )

Write the current stacktrace to stderr and LOG() with level = ALERT.

Definition at line 361 of file osutils.cpp.

361 {
362
363 // we overload st here...
364#if defined(_WIN32) || defined(_WIN64)
365#if BOOST_VERSION > 106500
366 boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace();
367 unsigned st_size = st.size();
368#else
369 char** st = NULL;
370 unsigned st_size = 0;
371#endif
372#else
373 char** st;
374 unsigned st_size = 0;
375 void* callstack[1024];
376 st_size = backtrace(callstack, 1024);
377 st = backtrace_symbols(callstack, st_size);
378#endif
379
380 // Write st_size and st[] to both std::cerr and ALOG
381 std::cerr << "Stacktrace " << st_size << " frames:" << std::endl;
382 ALOG("Stacktrace " << st_size << " frames:")
383 for (unsigned int i = 0; i < st_size; i++) {
384 std::cerr << "#" << i << " " << st[i] << std::endl;
385 ALOG("#" << i << " " << st[i]);
386 }
387
388#if defined(_WIN32) || defined(_WIN64)
389#else
390 if (st)
391 free(st);
392#endif
393}

◆ setAssertHandler()

void setAssertHandler ( )

Set an assert handler that logs the stacktrace.

Definition at line 405 of file osutils.cpp.

405 {
406 ALOG("Setting ORE+ SigAction handler to intercept SIGABRT signals");
407
408 // Just in case someone calls this twice
409 static bool sigaction_is_set = false;
410 if (!sigaction_is_set) {
411 struct sigaction psa;
412 psa.sa_handler = _oreplus_handler;
413 sigaction(SIGABRT, &psa, NULL);
414 sigaction(SIGSEGV, &psa, NULL);
415 sigaction_is_set = true;
416 }
417}

◆ parseDate()

QuantLib::Date parseDate ( const string &  s)

Convert std::string to QuantLib::Date.

Definition at line 51 of file parsers.cpp.

51 {
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}
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseReal()

QuantLib::Real parseReal ( const string &  s)

Convert text to Real.

Definition at line 112 of file parsers.cpp.

112 {
113 try {
114 return std::stod(s);
115 } catch (const std::exception& ex) {
116 QL_FAIL("Failed to parseReal(\"" << s << "\") " << ex.what());
117 }
118}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseRealOrNull()

Real parseRealOrNull ( const string &  s)

Convert text to Real, empty string to Null<Real>()

Definition at line 120 of file parsers.cpp.

120 {
121 if(s.empty())
122 return Null<Real>();
123 return parseReal(s);
124}
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tryParseReal()

bool tryParseReal ( const string &  s,
QuantLib::Real &  result 
)

Attempt to convert text to Real.

Attempts to convert text to Real

Parameters
[in]sThe string we wish to convert to a Real
[out]resultThe result of the conversion if it is valid. Null<Real>() if conversion fails
Returns
True if the conversion was successful, False if not

Definition at line 126 of file parsers.cpp.

126 {
127 try {
128 result = std::stod(s);
129 } catch (...) {
130 result = Null<Real>();
131 return false;
132 }
133 return true;
134}
+ Here is the caller graph for this function:

◆ parseInteger()

QuantLib::Integer parseInteger ( const string &  s)

Convert text to QuantLib::Integer.

Definition at line 136 of file parsers.cpp.

136 {
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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseBool()

bool parseBool ( const string &  s)

Convert text to bool.

Definition at line 144 of file parsers.cpp.

144 {
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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseCalendar()

QuantLib::Calendar parseCalendar ( const string &  s)

Convert text to QuantLib::Calendar.

For a joint calendar, the separate calendar names should be comma-delimited.

Definition at line 157 of file parsers.cpp.

157{ return CalendarParser::instance().parseCalendar(s); }
+ Here is the caller graph for this function:

◆ parsePeriod()

QuantLib::Period parsePeriod ( const string &  s)

Convert text to QuantLib::Period.

Definition at line 171 of file parsers.cpp.

171{ return PeriodParser::parse(s); }
+ Here is the caller graph for this function:

◆ parseBusinessDayConvention()

QuantLib::BusinessDayConvention parseBusinessDayConvention ( const string &  s)

Convert text to QuantLib::BusinessDayConvention.

Definition at line 173 of file parsers.cpp.

173 {
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}
+ Here is the caller graph for this function:

◆ parseDayCounter()

QuantLib::DayCounter parseDayCounter ( const string &  s)

Convert text to QuantLib::DayCounter.

Definition at line 209 of file parsers.cpp.

209 {
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}
+ Here is the caller graph for this function:

◆ parseCurrency()

QuantLib::Currency parseCurrency ( const string &  s)

Convert text to QuantLib::Currency.

Definition at line 290 of file parsers.cpp.

290{ return CurrencyParser::instance().parseCurrency(s); }
+ Here is the caller graph for this function:

◆ parseCurrencyType()

QuantExt::ConfigurableCurrency::Type parseCurrencyType ( const string &  s)

Convert text to QuantExt::ConfigurableCurrency::Type (Major, Minor, Metal, Crypto)

Definition at line 292 of file parsers.cpp.

292 {
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}
+ Here is the caller graph for this function:

◆ parseMinorCurrency()

QuantLib::Currency parseMinorCurrency ( const string &  s)

Convert text to QuantLib::Currency for minor currencies e.g GBp -> GBPCurrency()

Definition at line 308 of file parsers.cpp.

308{ return CurrencyParser::instance().parseMinorCurrency(s); }

◆ parseCurrencyWithMinors()

QuantLib::Currency parseCurrencyWithMinors ( const string &  s)

Convert text to QuantLib::Currency.

Definition at line 310 of file parsers.cpp.

310{ return CurrencyParser::instance().parseCurrencyWithMinors(s); }
+ Here is the caller graph for this function:

◆ parseCurrencyPair()

std::pair< QuantLib::Currency, QuantLib::Currency > parseCurrencyPair ( const string &  s,
const string &  delimiters 
)

Convert text to std::pair<QuantLib::Currency, QuantLib::Currency>

Definition at line 312 of file parsers.cpp.

312 {
313 return CurrencyParser::instance().parseCurrencyPair(s, delimiters);
314}

◆ checkCurrency()

bool checkCurrency ( const string &  code)

check for vaid currency code, including minors and pseudo currencies

Definition at line 316 of file parsers.cpp.

316{ return CurrencyParser::instance().isValidCurrency(code); }

◆ isPseudoCurrency()

bool isPseudoCurrency ( const string &  code)

check for pseudo currency = precious metal or crypto currency *‍/

Definition at line 318 of file parsers.cpp.

318{ return CurrencyParser::instance().isPseudoCurrency(code); }
+ Here is the caller graph for this function:

◆ isPreciousMetal()

bool isPreciousMetal ( const string &  code)

check for precious metal *‍/

Definition at line 320 of file parsers.cpp.

320{ return CurrencyParser::instance().isPreciousMetal(code); }

◆ isCryptoCurrency()

bool isCryptoCurrency ( const string &  code)

check for crypto currency *‍/

Definition at line 322 of file parsers.cpp.

322{ return CurrencyParser::instance().isCryptoCurrency(code); }

◆ convertMinorToMajorCurrency()

QuantLib::Real convertMinorToMajorCurrency ( const std::string &  s,
QuantLib::Real  value 
)

Convert a value from a minor ccy to major.

.i.e 100 GBp to 1 GBP

Definition at line 324 of file parsers.cpp.

324 {
325 return CurrencyParser::instance().convertMinorToMajorCurrency(s, value);
326}
SafeStack< ValueType > value
+ Here is the caller graph for this function:

◆ parseDateGenerationRule()

QuantLib::DateGeneration::Rule parseDateGenerationRule ( const string &  s)

Convert text to QuantLib::DateGeneration::Rule.

Definition at line 328 of file parsers.cpp.

328 {
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}
+ Here is the caller graph for this function:

◆ parseFrequency()

QuantLib::Frequency parseFrequency ( const string &  s)

Convert text to QuantLib::Frequency.

Definition at line 348 of file parsers.cpp.

348 {
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}
+ Here is the caller graph for this function:

◆ parseCompounding()

QuantLib::Compounding parseCompounding ( const string &  s)

Convert text to QuantLib::Compounding;.

Definition at line 376 of file parsers.cpp.

376 {
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}
+ Here is the caller graph for this function:

◆ parsePositionType()

QuantLib::Position::Type parsePositionType ( const std::string &  s)

Convert text to QuantLib::Position::Type.

Definition at line 404 of file parsers.cpp.

404 {
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}
+ Here is the caller graph for this function:

◆ parseProtectionSide()

QuantLib::Protection::Side parseProtectionSide ( const std::string &  s)

Convert text to QuantLib::Protection::Side.

Definition at line 420 of file parsers.cpp.

420 {
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}

◆ parseSettlementType()

QuantLib::Settlement::Type parseSettlementType ( const std::string &  s)

Convert text to QuantLib::Settlement::Type.

Definition at line 434 of file parsers.cpp.

434 {
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}
+ Here is the caller graph for this function:

◆ parseSettlementMethod()

QuantLib::Settlement::Method parseSettlementMethod ( const std::string &  s)

Convert text to QuantLib::Settlement::Method.

Definition at line 450 of file parsers.cpp.

450 {
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}
+ Here is the caller graph for this function:

◆ parseExerciseType()

QuantLib::Exercise::Type parseExerciseType ( const std::string &  s)

Convert text to QuantLib::Exercise::Type.

Definition at line 466 of file parsers.cpp.

466 {
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}
+ Here is the caller graph for this function:

◆ parseOptionType()

QuantLib::Option::Type parseOptionType ( const std::string &  s)

Convert text to QuantLib::Option::Type.

Definition at line 481 of file parsers.cpp.

481 {
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}
+ Here is the caller graph for this function:

◆ parseBondPriceType()

QuantLib::Bond::Price::Type parseBondPriceType ( const string &  s)

Convert text to QuantLib::Bond::Price::Type.

Definition at line 392 of file parsers.cpp.

392 {
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}
+ Here is the caller graph for this function:

◆ parseDateOrPeriod() [1/2]

boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod ( const string &  s)

Convert text to QuantLib::Period or QuantLib::Date.

Definition at line 493 of file parsers.cpp.

493 {
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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseDateOrPeriod() [2/2]

void parseDateOrPeriod ( const string &  s,
QuantLib::Date &  d,
QuantLib::Period &  p,
bool isDate 
)

Convert text to QuantLib::Period or QuantLib::Date (deprecated version)

◆ parsePolynomType()

QuantLib::LsmBasisSystem::PolynomialType parsePolynomType ( const std::string &  s)

Convert text to QuantLib::LsmBasisSystem::PolynomialType.

Definition at line 527 of file parsers.cpp.

527 {
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}
+ Here is the caller graph for this function:

◆ operator<<() [1/6]

std::ostream & operator<< ( std::ostream &  os,
QuantLib::LsmBasisSystem::PolynomialType  a 
)

Write QuantLib::LsmBasisSystem::PolynomialType to stream.

Definition at line 546 of file parsers.cpp.

546 {
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}

◆ parseSobolBrownianGeneratorOrdering()

QuantLib::SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering ( const std::string &  s)

Convert text to QuantLib::SobolBrownianGenerator::Ordering.

Definition at line 567 of file parsers.cpp.

567 {
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}
+ Here is the caller graph for this function:

◆ parseSobolRsgDirectionIntegers()

QuantLib::SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers ( const std::string &  s)

Convert text to QuantLib::SobolRsg::DirectionIntegers.

Definition at line 579 of file parsers.cpp.

579 {
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}
+ Here is the caller graph for this function:

◆ parseWeekday()

QuantLib::Weekday parseWeekday ( const std::string &  s)

Convert text to QuantLib::Weekday

Definition at line 599 of file parsers.cpp.

599 {
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}
+ Here is the caller graph for this function:

◆ parseMonth()

QuantLib::Month parseMonth ( const std::string &  s)

Convert text to QuantLib::Month

Definition at line 613 of file parsers.cpp.

613 {
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}
+ Here is the caller graph for this function:

◆ parsePaymentLag()

PaymentLag parsePaymentLag ( const string &  s)

Convert text to PaymentLag.

Definition at line 628 of file parsers.cpp.

628 {
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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseListOfValues()

std::vector< T > parseListOfValues ( string  s,
std::function< T(string)>  parser 
)

Convert comma separated list of values to vector of values.

Definition at line 323 of file parsers.hpp.

323 {
324 boost::trim(s);
325 std::vector<T> vec;
326 boost::char_separator<char> sep(",");
327 boost::tokenizer<boost::char_separator<char>> tokens(s, sep);
328 for (auto r : tokens) {
329 boost::trim(r);
330 vec.push_back(parser(r));
331 }
332 return vec;
333}

◆ parseSequenceType()

QuantExt::SequenceType parseSequenceType ( const std::string &  s)

Convert string to sequence type.

Definition at line 668 of file parsers.cpp.

668 {
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}
+ Here is the caller graph for this function:

◆ parseObservationInterpolation()

QuantLib::CPI::InterpolationType parseObservationInterpolation ( const std::string &  s)

Convert string to observation interpolation.

Definition at line 682 of file parsers.cpp.

682 {
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}
+ Here is the caller graph for this function:

◆ parseFdmSchemeDesc()

QuantLib::FdmSchemeDesc parseFdmSchemeDesc ( const std::string &  s)

Convert string to fdm scheme desc.

Definition at line 692 of file parsers.cpp.

692 {
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}
+ Here is the caller graph for this function:

◆ parseAssetClass()

AssetClass parseAssetClass ( const std::string &  s)

Convert text to ore::data::AssetClass.

Definition at line 710 of file parsers.cpp.

710 {
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}

◆ operator<<() [2/6]

std::ostream & operator<< ( std::ostream &  os,
AssetClass  a 
)

Write ore::data::AssetClass to stream.

Definition at line 723 of file parsers.cpp.

723 {
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";
739 case AssetClass::BOND_INDEX:
740 return os << "BOND_INDEX";
741 default:
742 QL_FAIL("Unknown AssetClass");
743 }
744}

◆ parseAtmType()

QuantLib::DeltaVolQuote::AtmType parseAtmType ( const std::string &  s)

Convert text to QuantLib::DeltaVolQuote::AtmType.

Definition at line 746 of file parsers.cpp.

746 {
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}
+ Here is the caller graph for this function:

◆ parseDeltaType()

QuantLib::DeltaVolQuote::DeltaType parseDeltaType ( const std::string &  s)

Convert text to QuantLib::DeltaVolQuote::DeltaType.

Definition at line 763 of file parsers.cpp.

763 {
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}
+ Here is the caller graph for this function:

◆ parseRoundingType()

QuantLib::Rounding::Type parseRoundingType ( const std::string &  s)

Convert text to QuantLib::Rounding.

Definition at line 1027 of file parsers.cpp.

1027 {
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}
+ Here is the caller graph for this function:

◆ parseBarrierType()

QuantLib::Barrier::Type parseBarrierType ( const std::string &  s)

Convert std::string to QuantLib::BarrierType.

Definition at line 1042 of file parsers.cpp.

1042 {
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}
+ Here is the caller graph for this function:

◆ parseDoubleBarrierType()

QuantLib::DoubleBarrier::Type parseDoubleBarrierType ( const std::string &  s)

Convert std::string to QuantLib::DoubleBarrierType.

Definition at line 1061 of file parsers.cpp.

1061 {
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}
+ Here is the caller graph for this function:

◆ tryParse()

bool tryParse ( const std::string &  str,
T &  obj,
std::function< T(const std::string &)>  parser 
)

Attempt to parse string str to obj of type T using parser

Parameters
[in]strThe string we wish to parse.
[out]objThe resulting object if the parsing was successful.
[in]parserThe function to use to attempt to parse str. This function may throw.
Returns
true if the parsing was successful and false if not.

Definition at line 427 of file parsers.hpp.

427 {
428 DLOG("tryParse: attempting to parse " << str);
429 try {
430 obj = parser(str);
431 } catch (...) {
432 TLOG("String " << str << " could not be parsed");
433 return false;
434 }
435 return true;
436}
MarketObject obj
+ Here is the caller graph for this function:

◆ parseVolatilityQuoteType()

QuantLib::VolatilityType parseVolatilityQuoteType ( const std::string &  s)

Convert text to QuantLib::VolatilityType

Definition at line 804 of file parsers.cpp.

804 {
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}

◆ parseCapFloorType()

QuantLib::CapFloor::Type parseCapFloorType ( const std::string &  s)

Convert text to QuantLib::CapFloor::Type

Definition at line 815 of file parsers.cpp.

815 {
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}
+ Here is the caller graph for this function:

◆ parseYoYInflationCapFloorType()

QuantLib::YoYInflationCapFloor::Type parseYoYInflationCapFloorType ( const std::string &  s)

Convert text to QuantLib::YoYInflationCapFloor::Type

Definition at line 827 of file parsers.cpp.

827 {
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}
+ Here is the caller graph for this function:

◆ parseCamAssetType()

QuantExt::CrossAssetModel::AssetType parseCamAssetType ( const std::string &  s)

Convert text to QuantExt::CrossAssetModelTypes::AssetType

Definition at line 839 of file parsers.cpp.

839 {
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}
+ Here is the caller graph for this function:

◆ parseBoostAny()

std::pair< string, string > parseBoostAny ( const boost::any &  anyType,
Size  precision = 8 
)

Convert boost::any to pair<string,string>, including the valueType and the value

Definition at line 859 of file parsers.cpp.

859 {
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}
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseCdsOptionStrikeType()

QuantExt::CdsOption::StrikeType parseCdsOptionStrikeType ( const std::string &  s)

Convert text to QuantExt::CdsOption::StrikeType

Definition at line 1240 of file parsers.cpp.

1240 {
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}
+ Here is the caller graph for this function:

◆ parseAverageType()

QuantLib::Average::Type parseAverageType ( const std::string &  s)

Convert text to QuantLib::Average::Type

Definition at line 1251 of file parsers.cpp.

1251 {
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}

◆ parsePriceQuoteMethod()

QuantExt::BondIndex::PriceQuoteMethod parsePriceQuoteMethod ( const std::string &  s)

Convert text to QuantExt::BondData::PriceQuoteMethod

Definition at line 1261 of file parsers.cpp.

1261 {
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}
+ Here is the caller graph for this function:

◆ fxDominance()

string fxDominance ( const string &  s1,
const string &  s2 
)

Convert FX pair to market standard dominance.

Convert FX pair to market standard dominance, e.g. "USD" & "GBP" -> "GBPUSD", "USD" & "JPY" -> "USDJPY"

Definition at line 1296 of file parsers.cpp.

1296 {
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}
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
+ Here is the caller graph for this function:

◆ parseMomentType()

MomentType parseMomentType ( const std::string &  s)

Convert text to ore::data::MomentType.

Definition at line 1361 of file parsers.cpp.

1361 {
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}
+ Here is the caller graph for this function:

◆ parsePillarChoice()

QuantLib::Pillar::Choice parsePillarChoice ( const std::string &  s)

Convert text to QuantLib::Pillar::Choice.

Definition at line 1403 of file parsers.cpp.

1403 {
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}
+ Here is the caller graph for this function:

◆ parseRegressorModel()

QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel ( const std::string &  s)

Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel.

Definition at line 1418 of file parsers.cpp.

1418 {
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}
+ Here is the caller graph for this function:

◆ parseMporCashFlowMode()

MporCashFlowMode parseMporCashFlowMode ( const string &  s)

Convert text to MporCashFlowMode.

Definition at line 1428 of file parsers.cpp.

1428 {
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}

◆ operator<<() [3/6]

std::ostream & operator<< ( std::ostream &  out,
MporCashFlowMode  t 
)

Write MporCashFlowMode to stream.

Definition at line 1441 of file parsers.cpp.

1441 {
1442 if (t == MporCashFlowMode::Unspecified)
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}

◆ parseSabrParametricVolatilityModelVariant()

QuantExt::SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant ( const std::string &  s)

Parse SabrParametricVolatility::ModelVariant.

Definition at line 1458 of file parsers.cpp.

1458 {
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}
+ Here is the caller graph for this function:

◆ operator<<() [4/6]

std::ostream & operator<< ( std::ostream &  out,
QuantExt::SabrParametricVolatility::ModelVariant  m 
)

Write SabrParametricVolatility::ModelVariant.

◆ operator<<() [5/6]

std::ostream & operator<< ( std::ostream &  os,
QuantLib::Exercise::Type  type 
)

Write QuantLib::Exercise::Type.

◆ serialize() [1/3]

void serialize ( Archive &  ar,
QuantLib::Date &  d,
const unsigned int   
)

Allow for serialization of QuantLib::Date without amending its class (non-intrusive)

Definition at line 37 of file serializationdate.hpp.

37 {
38 QuantLib::Date::serial_type big;
39 if (Archive::is_saving::value) {
40 // When serializing, convert to long and save
41 big = d.serialNumber();
42 ar& big;
43 } else {
44 // When deserializing, write out saved long and convert to Date
45 ar& big;
46 if (big == 0)
47 d = QuantLib::Date();
48 else
49 d = QuantLib::Date(big);
50 }
51}

◆ serialize() [2/3]

void serialize ( Archive &  ar,
QuantLib::DayCounter &  dc,
const unsigned int   
)

Allow for serialization of QuantLib::Period without amending its class (non-intrusive)

Definition at line 39 of file serializationdaycounter.hpp.

39 {
40 // handle the day counter via the name
41 std::string dcName;
42 if (Archive::is_saving::value) {
43 dcName = dc.empty() ? "" : dc.name();
44 ar& dcName;
45 } else {
46 ar& dcName;
47 if (!dcName.empty()) {
48 try {
49 dc = ore::data::parseDayCounter(dcName);
50 } catch (const std::exception& e) {
51 QL_FAIL("could not deserialize day counter, please extend parseDayCounter(): " << e.what());
52 }
53 }
54 }
55}
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Definition: parsers.cpp:209
+ Here is the call graph for this function:

◆ serialize() [3/3]

void serialize ( Archive &  ar,
QuantLib::Period &  p,
const unsigned int   
)

Allow for serialization of QuantLib::Period without amending its class (non-intrusive)

Definition at line 37 of file serializationperiod.hpp.

37 {
38 QuantLib::Integer length;
39 QuantLib::TimeUnit units;
40 if (Archive::is_saving::value) {
41 length = p.length();
42 units = p.units();
43 ar& length;
44 ar& units;
45 } else {
46 ar& length;
47 ar& units;
48 p = QuantLib::Period(length, units);
49 }
50}

◆ parseStrike()

Strike parseStrike ( const std::string &  s)

Convert text to Strike.

Definition at line 30 of file strike.cpp.

30 {
31 static boost::mutex mutex_;
32 boost::lock_guard<boost::mutex> lock(mutex_);
33
34 boost::regex m1("^(ATM|atm)");
35 boost::regex m1b("^(ATMF|atmf)");
36 boost::regex m2("^(ATM|atm)(\\+|\\-)([0-9]+[.]?[0-9]*)");
37 boost::regex m3("^(\\+|\\-)?([0-9]+[.]?[0-9]*)");
38 boost::regex m4("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(d|D)");
39 boost::regex m4b("(d|D)");
40 boost::regex m5("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(c|C)");
41 boost::regex m5b("^(c|C)");
42 boost::regex m6("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(p|P)");
43 boost::regex m6b("^(p|P)");
44 boost::regex m7("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(bf|BF)");
45 boost::regex m7b("^(bf|BF)");
46 boost::regex m8("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(rr|RR)");
47 boost::regex m8b("^(rr|RR)");
48 boost::regex m9("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(ATMF|atmf)");
49 boost::regex m9b("(ATMF|atmf)");
50 boost::regex m10("^(\\+|\\-)?([0-9]+[.]?[0-9]*)(ATM|atm)");
51 boost::regex m10b("(ATM|atm)");
52 Strike result;
53 if (boost::regex_match(s, m1)) {
54 result.type = Strike::Type::ATM;
55 result.value = 0.0;
56 return result;
57 }
58 if (boost::regex_match(s, m1b)) {
59 result.type = Strike::Type::ATMF;
60 result.value = 0.0;
61 return result;
62 }
63 if (boost::regex_match(s, m2)) {
64 result.type = Strike::Type::ATM_Offset;
65 result.value = parseReal(regex_replace(s, m1, std::string("")));
66 return result;
67 }
68 if (boost::regex_match(s, m3)) {
69 result.type = Strike::Type::Absolute;
70 result.value = parseReal(s);
71 return result;
72 }
73 if (boost::regex_match(s, m4)) {
74 result.type = Strike::Type::Delta;
75 result.value = parseReal(regex_replace(s, m4b, std::string("")));
76 return result;
77 }
78 if (boost::regex_match(s, m5)) {
79 result.type = Strike::Type::DeltaCall;
80 result.value = parseReal(regex_replace(s, m5b, std::string("")));
81 return result;
82 }
83 if (boost::regex_match(s, m6)) {
84 result.type = Strike::Type::DeltaPut;
85 result.value = parseReal(regex_replace(s, m6b, std::string("")));
86 return result;
87 }
88 if (boost::regex_match(s, m7)) {
89 result.type = Strike::Type::BF;
90 result.value = parseReal(regex_replace(s, m7b, std::string("")));
91 return result;
92 }
93 if (boost::regex_match(s, m8)) {
94 result.type = Strike::Type::RR;
95 result.value = parseReal(regex_replace(s, m8b, std::string("")));
96 return result;
97 }
98 if (boost::regex_match(s, m9)) {
99 result.type = Strike::Type::ATMF_Moneyness;
100 result.value = parseReal(regex_replace(s, m9b, std::string("")));
101 return result;
102 }
103 if (boost::regex_match(s, m10)) {
104 result.type = Strike::Type::ATM_Moneyness;
105 result.value = parseReal(regex_replace(s, m10b, std::string("")));
106 return result;
107 }
108 QL_FAIL("could not parse strike given by " << s);
109}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [6/6]

std::ostream & operator<< ( std::ostream &  out,
const Strike s 
)

Convert Strike to text.

Definition at line 111 of file strike.cpp.

111 {
112 switch (s.type) {
113 case Strike::Type::ATM:
114 out << "ATM";
115 break;
116 case Strike::Type::ATMF:
117 out << "ATMF";
118 break;
119 case Strike::Type::ATM_Offset:
120 out << "ATM_Offset";
121 break;
122 case Strike::Type::Absolute:
123 out << "Absolute";
124 break;
125 case Strike::Type::Delta:
126 out << "Delta";
127 break;
128 case Strike::Type::ATMF_Moneyness:
129 out << "ATMF_Moneyness";
130 break;
131 case Strike::Type::ATM_Moneyness:
132 out << "ATM_Moneyness";
133 break;
134 default:
135 out << "UNKNOWN";
136 break;
137 }
138 if (s.type == Strike::Type::ATM_Offset || s.type == Strike::Type::Absolute || s.type == Strike::Type::Delta ||
139 s.type == Strike::Type::ATMF_Moneyness || s.type == Strike::Type::ATM_Moneyness) {
140 if (s.value >= 0.0)
141 out << "+";
142 else
143 out << "-";
144 out << s.value;
145 }
146 return out;
147}

◆ operator==()

bool operator== ( const Strike s1,
const Strike s2 
)

Logical comparison of strikes.

Definition at line 161 of file strike.cpp.

161 {
162 Strike tmp1 = normaliseStrike(s1);
163 Strike tmp2 = normaliseStrike(s2);
164 return (tmp1.type == tmp2.type && QuantLib::close_enough(tmp1.value, tmp2.value));
165}

◆ computeAbsoluteStrike()

QuantLib::Real computeAbsoluteStrike ( const Strike s,
const QuantLib::Real  atm,
const QuantLib::Real  atmf 
)

Convenience function that computes an absolute strike.

Definition at line 167 of file strike.cpp.

167 {
168 switch (s.type) {
169 case Strike::Type::ATM:
170 return atm;
171 case Strike::Type::ATMF:
172 return atmf;
173 case Strike::Type::ATM_Offset:
174 return atm + s.value;
175 case Strike::Type::Absolute:
176 return s.value;
177 case Strike::Type::Delta:
178 QL_FAIL("can not compute absolute strike for type delta");
179 case Strike::Type::ATMF_Moneyness:
180 return atmf * s.value;
181 case Strike::Type::ATM_Moneyness:
182 return atm * s.value;
183 default:
184 QL_FAIL("can not compute strike for unknown type " << s);
185 }
186}

◆ to_string() [1/6]

std::string to_string ( const QuantLib::Date &  date)

Convert QuantLib::Date to std::string.

Returns date as a string in YYYY-MM-DD format, which matches QuantLib::io::iso_date() However that function can have issues with locale so we have a local snprintf() based version.

If date == Date() returns 1900-01-01 so the above format is preserved.

+ Here is the call graph for this function:

◆ to_string() [2/6]

std::string to_string ( bool  aBool)

Convert bool to std::string.

Returns "true" for true and "false" for false

Definition at line 57 of file to_string.cpp.

57{ return aBool ? "true" : "false"; }
+ Here is the call graph for this function:

◆ to_string() [3/6]

std::string to_string ( const QuantLib::Period &  period)

Convert QuantLib::Period to std::string.

Returns Period as a string as up to QuantLib 1.25, e.g. 13M is written as 1Y1M etc.

+ Here is the call graph for this function:

◆ to_string() [4/6]

std::string to_string ( const std::vector< T > &  vec,
const std::string &  sep = "," 
)

Convert vector to std::string.

Returns a vector into a single string, with elemenst separated by Period as a string as up to QuantLib 1.25, e.g. 13M is written as 1Y1M etc.

Definition at line 66 of file to_string.hpp.

66 {
67 std::ostringstream oss;
68 for (std::size_t i = 0; i < vec.size(); ++i) {
69 oss << vec[i];
70 if (i < vec.size() - 1)
71 oss << sep;
72 }
73 return oss.str();
74}
+ Here is the call graph for this function:

◆ to_string() [5/6]

std::string to_string ( const std::set< T > &  set,
const std::string &  sep = "," 
)

Convert set to std::string.

Definition at line 80 of file to_string.hpp.

80 {
81 std::ostringstream oss;
82 std::size_t count = 1;
83 for (auto s: set) {
84 oss << s;
85 if (count < set.size())
86 oss << sep;
87 count++;
88 }
89 return oss.str();
90}
std::size_t count
+ Here is the call graph for this function:

◆ to_string() [6/6]

std::string to_string ( const T &  t)

Convert type to std::string.

Utility to give to_string() interface to classes and enums that have ostream<< operators defined.

Definition at line 97 of file to_string.hpp.

97 {
98 std::ostringstream oss;
99 oss << t;
100 return oss.str();
101}
+ Here is the call graph for this function:

◆ sort_permutation()

std::vector< std::size_t > sort_permutation ( const std::vector< T > &  vec,
Compare &  compare 
)

Definition at line 38 of file vectorutils.hpp.

38 {
39 std::vector<std::size_t> p(vec.size());
40 std::iota(p.begin(), p.end(), 0);
41 std::sort(p.begin(), p.end(), [&](std::size_t i, std::size_t j) { return compare(vec[i], vec[j]); });
42 return p;
43}
+ Here is the caller graph for this function:

◆ apply_permutation()

std::vector< T > apply_permutation ( const std::vector< T > &  vec,
const std::vector< std::size_t > &  p 
)

Definition at line 45 of file vectorutils.hpp.

45 {
46 std::vector<T> sorted_vec(vec.size());
47 std::transform(p.begin(), p.end(), sorted_vec.begin(), [&](std::size_t i) { return vec[i]; });
48 return sorted_vec;
49}

◆ apply_permutation_in_place()

void apply_permutation_in_place ( std::vector< T > &  vec,
const std::vector< std::size_t > &  p 
)

Definition at line 51 of file vectorutils.hpp.

51 {
52 std::vector<bool> done(vec.size());
53 for (std::size_t i = 0; i < vec.size(); ++i) {
54 if (done[i])
55 continue;
56 done[i] = true;
57 for (std::size_t j = p[i]; i != j; j = p[j]) {
58 std::swap(vec[i], vec[j]);
59 done[j] = true;
60 }
61 }
62}
+ Here is the caller graph for this function: