25#include <ql/errors.hpp>
27#include <boost/algorithm/string.hpp>
35 return out <<
"RATE_LNVOL";
37 return out <<
"RATE_NVOL";
39 return out <<
"RATE_SLNVOL";
41 QL_FAIL(
"unknown VolatilityType(" << Integer(t) <<
")");
48 return out <<
"PRICE";
50 return out <<
"VOLATILITY";
52 QL_FAIL(
"unknown QuoteType(" << Integer(t) <<
")");
57 const string& curveID,
const string& curveDescription,
const Type type,
const QuoteType& quoteType,
59 const vector<string>& capStrikes,
const vector<string>& floorStrikes,
const vector<string>& strikes,
60 const DayCounter& dayCounter, Natural settleDays,
const Calendar&
calendar,
61 const BusinessDayConvention& businessDayConvention,
const string& index,
const string& indexCurve,
62 const string& yieldTermStructure,
const Period& observationLag,
const string& quoteIndex,
const string& conventions,
63 const bool useLastAvailableFixingDate)
65 extrapolate_(extrapolate), tenors_(tenors), capStrikes_(capStrikes), floorStrikes_(floorStrikes),
66 strikes_(
strikes), dayCounter_(dayCounter), settleDays_(settleDays), calendar_(
calendar),
67 businessDayConvention_(businessDayConvention), index_(index), indexCurve_(indexCurve),
68 yieldTermStructure_(yieldTermStructure), observationLag_(observationLag), quoteIndex_(quoteIndex),
69 conventions_(conventions), useLastAvailableFixingDate_(useLastAvailableFixingDate) {
92 std::stringstream ssBase;
94 ssBase <<
type <<
"_INFLATIONCAPFLOOR/PRICE/" <<
index <<
"/";
97 string base = ssBase.str();
103 quotes_.push_back(base + t +
"/C/" + s);
106 quotes_.push_back(base + t +
"/F/" + s);
110 quotes_.push_back(base + t +
"/F/" + s);
117 std::stringstream ss;
134 }
else if (
type ==
"YY") {
137 QL_FAIL(
"Type " <<
type <<
" not recognized");
146 QL_FAIL(
"Quote type, " <<
quoteType <<
", not recognized");
151 if (volType ==
"Normal") {
153 }
else if (volType ==
"Lognormal") {
155 }
else if (volType ==
"ShiftedLognormal") {
158 QL_FAIL(
"Volatility type, " << volType <<
", not recognized");
168 "CapStrikes or FloorStrikes node should not be empty");
170 std::set<Real> strikeSet;
176 for (
auto s : strikeSet)
178 for (Size i = 0; i <
strikes_.size(); ++i)
179 DLOG(
"ZC Inflation Cap/Floor Strike " << i <<
" = " <<
strikes_[i]);
182 QL_REQUIRE(!
strikes_.empty(),
"Strikes node should not be empty");
187 QL_REQUIRE(d >= 0,
"SettlementDays (" << d <<
") must be non-negative");
215 QL_FAIL(
"Unknown Type in InflationCapFloorVolatilityCurveConfig::toXML()");
222 QL_FAIL(
"Unknown QuoteType in InflationCapFloorVolatilityCurveConfig::toXML()");
232 QL_FAIL(
"Unknown VolatilityType in InflationCapFloorVolatilityCurveConfig::toXML()");
Base curve configuration.
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
void populateRequiredCurveIds()
const Type & type() const
const string & yieldTermStructure() const
vector< string > strikes_
const string & index() const
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const vector< string > & quotes() override
Return all the market quotes required for this config.
vector< string > floorStrikes_
bool useLastAvailableFixingDate_
InflationCapFloorVolatilityCurveConfig()
const string & indexCurve() const
const QuoteType & quoteType() const
string yieldTermStructure_
vector< string > capStrikes_
VolatilityType volatilityType_
BusinessDayConvention businessDayConvention_
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 bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
Get a node's value.
static vector< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
QuantLib::ext::shared_ptr< CurveSpec > parseCurveSpec(const string &s)
function to convert a string into a curve spec
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.
Real parseReal(const string &s)
Convert text to Real.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Map text representations to QuantLib/QuantExt types.
Inflation CapFloor volatility curve configuration class.
#define DLOG(text)
Logging Macro (Level = Debug)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
VolatilityType volatilityType(CapFloorVolatilityCurveConfig::VolatilityType type)
Imply QuantLib::VolatilityType from CapFloorVolatilityCurveConfig::VolatilityType.
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities