19#include <boost/algorithm/string.hpp>
24#include <ql/errors.hpp>
25#include <ql/time/calendars/nullcalendar.hpp>
26#include <ql/time/daycounters/actualactual.hpp>
33 return out <<
"CMSSpread";
35 return out <<
"Generic";
37 QL_FAIL(
"unknown QuoteType(" << Integer(t) <<
")");
45 return out <<
"Constant";
47 QL_FAIL(
"unknown Dimension(" << Integer(t) <<
")");
54 const bool extrapolate,
const vector<string>& optionTenors,
55 const DayCounter& dayCounter,
const Calendar&
calendar,
56 const BusinessDayConvention& businessDayConvention,
const string& index1,
57 const string& index2,
const string& currency,
const string& swaptionVol,
58 const string& discountCurve)
59 :
CurveConfig(curveID, curveDescription), dimension_(dimension), correlationType_(corrType),
60 conventions_(convention), quoteType_(quoteType), extrapolate_(extrapolate), optionTenors_(optionTenors),
61 dayCounter_(dayCounter), calendar_(
calendar), businessDayConvention_(businessDayConvention), index1_(index1),
62 index2_(index2), currency_(currency), swaptionVol_(swaptionVol), discountCurve_(discountCurve) {
68 "Only one tenor should be supplied for a constant correlation termstructure");
85 std::stringstream ssBase;
87 string base = ssBase.str();
91 ss << base <<
"/" << o <<
"/ATM";
105 if (corrType ==
"CMSSpread") {
107 }
else if (corrType ==
"Generic") {
110 QL_FAIL(
"Correlation type " << corrType <<
" not recognized");
118 }
else if (boost::iequals(
quoteType,
"PRICE")) {
120 }
else if (boost::iequals(
quoteType,
"NULL")) {
123 QL_FAIL(
"Quote type " <<
quoteType <<
" not recognized");
142 QL_REQUIRE(
optionTenors_.size() > 0,
"no option tenors supplied");
145 QL_REQUIRE(dim ==
"ATM" || dim ==
"Constant",
"Dimension " << dim <<
" not recognised");
147 if (dim ==
"Constant") {
149 QL_REQUIRE(
optionTenors_.size() == 1,
"Only one tenor should be supplied for a constant correlation termstructure");
225 vector<string> tokens1;
226 boost::split(tokens1, index1, boost::is_any_of(
"-"));
227 vector<string> tokens2;
228 boost::split(tokens2, index2, boost::is_any_of(
"-"));
230 QL_REQUIRE(tokens1.size() >= 2,
"at least two tokens expected in " << index1);
231 QL_REQUIRE(tokens2.size() >= 2,
"at least two tokens expected in " << index2);
235 if (tokens1[1] ==
"CMS")
237 else if (tokens1[0] ==
"FX")
239 else if (tokens1[0] ==
"EQ")
241 else if (tokens1[0] ==
"COMM")
246 if (tokens2[1] ==
"CMS")
248 else if (tokens2[0] ==
"FX")
250 else if (tokens2[0] ==
"EQ")
252 else if (tokens2[0] ==
"COMM")
263 if (s1 == 0 || s1 == 1)
264 return tokens1[1] < tokens2[1];
266 QL_REQUIRE(tokens1.size() >= 3,
"at least three tokens expected in " << index1);
267 QL_REQUIRE(tokens2.size() >= 3,
"at least three tokens expected in " << index2);
270 if (s1 == 3 || s1 == 4)
273 QL_REQUIRE(tokens1.size() >= 4,
"at least four tokens expected in " << index1);
274 QL_REQUIRE(tokens2.size() >= 4,
"at least four tokens expected in " << index2);
278 return (tokens1[2] +
"-" + tokens1[3]) < (tokens2[2] +
"-" + tokens2[3]);
281 QL_FAIL(
"indexNameLessThan(): internal error");
const string & swaptionVolatility() const
void populateRequiredCurveIds()
const vector< string > & optionTenors() const
const MarketDatum::QuoteType & quoteType() const
MarketDatum::QuoteType quoteType_
CorrelationCurveConfig()
Default constructor.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
CorrelationType correlationType_
vector< string > optionTenors_
const vector< string > & quotes() override
Return all the market quotes required for this config.
const string & discountCurve() const
const Dimension & dimension() const
CorrelationType
supported Correlation types
BusinessDayConvention businessDayConvention_
Dimension
supported Correlation dimensions
Base curve configuration.
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
QuoteType
Supported market quote types.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
static void checkNode(XMLNode *n, const string &expectedName)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static vector< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
bool parseBool(const string &s)
Convert text to bool.
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Map text representations to QuantLib/QuantExt types.
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
bool indexNameLessThan(const std::string &index1, const std::string &index2)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities