19#include <boost/algorithm/string.hpp>
26#include <ql/errors.hpp>
34 return out <<
"RATE_LNVOL";
36 return out <<
"RATE_NVOL";
38 return out <<
"RATE_SLNVOL";
40 QL_FAIL(
"unknown VolatilityType(" << Integer(t) <<
")");
45 const std::string& underlyingLabel,
const std::string& rootNodeLabel,
const std::string& marketDatumInstrumentLabel,
46 const std::string& qualifierLabel,
const string& curveID,
const string& curveDescription,
49 const vector<string>& optionTenors,
const vector<string>& underlyingTenors,
const DayCounter& dayCounter,
50 const Calendar&
calendar,
const BusinessDayConvention& businessDayConvention,
const string& shortSwapIndexBase,
51 const string& swapIndexBase,
const vector<string>& smileOptionTenors,
const vector<string>& smileUnderlyingTenors,
52 const vector<string>& smileSpreads,
53 const boost::optional<ParametricSmileConfiguration>& parametricSmileConfiguration)
54 :
CurveConfig(curveID, curveDescription), underlyingLabel_(underlyingLabel), rootNodeLabel_(rootNodeLabel),
55 marketDatumInstrumentLabel_(marketDatumInstrumentLabel), qualifierLabel_(qualifierLabel), allowSmile_(true),
56 requireSwapIndexBases_(false), qualifier_(qualifier), dimension_(dimension), volatilityType_(
volatilityType),
57 interpolation_(interpolation), extrapolation_(extrapolation), optionTenors_(optionTenors),
58 underlyingTenors_(underlyingTenors), dayCounter_(dayCounter), calendar_(
calendar),
59 businessDayConvention_(businessDayConvention), shortSwapIndexBase_(shortSwapIndexBase),
60 swapIndexBase_(swapIndexBase), smileOptionTenors_(smileOptionTenors),
61 smileUnderlyingTenors_(smileUnderlyingTenors), smileSpreads_(smileSpreads),
62 parametricSmileConfiguration_(parametricSmileConfiguration) {
68 "Smile tenors/strikes/spreads should only be set when dim=Smile");
77 const std::string& underlyingLabel,
const std::string& rootNodeLabel,
const std::string& qualifierLabel,
78 const string& curveID,
const string& curveDescription,
const string& qualifier,
79 const std::string& proxySourceCurveId,
const std::string& proxySourceShortSwapIndexBase,
80 const std::string& proxySourceSwapIndexBase,
const std::string& proxyTargetShortSwapIndexBase,
81 const std::string& proxyTargetSwapIndexBase)
82 :
CurveConfig(curveID, curveDescription), underlyingLabel_(underlyingLabel), rootNodeLabel_(rootNodeLabel),
83 qualifierLabel_(qualifierLabel), allowSmile_(true), requireSwapIndexBases_(false),
84 proxySourceShortSwapIndexBase_(proxySourceShortSwapIndexBase),
85 proxySourceSwapIndexBase_(proxySourceSwapIndexBase),
86 proxyTargetShortSwapIndexBase_(proxyTargetShortSwapIndexBase),
87 proxyTargetSwapIndexBase_(proxyTargetSwapIndexBase) {
106 std::stringstream ssBase;
110 string base = ssBase.str();
115 std::stringstream ss;
116 ss << base << o <<
"/" << s <<
"/ATM";
126 std::stringstream ss;
127 ss << base << o <<
"/" << s <<
"/Smile/" << sp;
136 std::stringstream ss;
147 std::vector<string> tokens;
149 QL_REQUIRE(!tokens.empty() && tokens[0] !=
"",
150 "GenericYieldVolatilityCurveConfig::fromXML(): can not derive qualifier from SwapIndexBase ("
165 QL_REQUIRE(source !=
nullptr,
166 "GenericYieldVolatilityCurveConfig::fromXML(): ProxyConfig requires child node 'Source'");
172 QL_REQUIRE(target !=
nullptr,
173 "GenericYieldVolatilityCurveConfig::fromXML(): ProxyConfig requires child node 'Target'");
185 }
else if (dim ==
"Smile") {
188 QL_FAIL(
"Dimension " << dim <<
" not recognized");
195 if (volType ==
"Normal") {
197 }
else if (volType ==
"Lognormal") {
199 }
else if (volType ==
"ShiftedLognormal") {
203 "VolatilityType '" << volType
204 <<
"' not recognized. Expected one of 'Normal', 'Lognormal', 'ShiftedLognormal'.");
208 if (outVolType.empty())
210 else if (outVolType ==
"Normal") {
212 }
else if (outVolType ==
"Lognormal") {
214 }
else if (outVolType ==
"ShiftedLognormal") {
217 QL_FAIL(
"OutputVolatilityType '"
218 << outVolType <<
"' not recognized. Expected one of 'Normal', 'Lognormal', 'ShiftedLognormal'.");
222 if (interp ==
"Linear") {
227 }
catch (
const std::exception& e) {
228 QL_FAIL(
"Interpolation '" << interp <<
"' not recognized. Expected 'Linear' or a SABR variant ("
234 if (extr ==
"Linear") {
236 }
else if (extr ==
"Flat") {
238 }
else if (extr ==
"None") {
241 QL_FAIL(
"Extrapolation " << extr <<
" not recognized, expected one of 'Linear', 'Flat', 'None'.");
317 QL_FAIL(
"Unknown Dimension in GenericYieldVolatilityCurveConfig::toXML()");
327 QL_FAIL(
"Unknown VolatilityType in GenericYieldVolatilityCurveConfig::toXML()");
337 QL_FAIL(
"Unknown OutputVolatilityType in GenericYieldVolatilityCurveConfig::toXML()");
340 std::string extr_string;
342 extr_string =
"None";
344 extr_string =
"Linear";
346 extr_string =
"Flat";
Base curve configuration.
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
vector< string > smileUnderlyingTenors_
void populateRequiredCurveIds()
ReportConfig reportConfig_
const string & swapIndexBase() const
string proxyTargetShortSwapIndexBase_
const string marketDatumInstrumentLabel_
const vector< string > & smileOptionTenors() const
const string underlyingLabel_
string proxySourceShortSwapIndexBase_
GenericYieldVolatilityCurveConfig(const std::string &underlyingLabel, const std::string &rootNodeLabel, const std::string &marketDatumInstrumentLabel, const std::string &qualifierLabel, const bool allowSmile, const bool requireSwapIndexBases)
Default constructor.
string ccyFromSwapIndexBase(const std::string &swapIndexBase)
vector< string > smileSpreads_
Interpolation interpolation_
void fromXML(XMLNode *node) override
Extrapolation extrapolation_
XMLNode * toXML(XMLDocument &doc) const override
vector< string > optionTenors_
VolatilityType outputVolatilityType_
const vector< string > & quotes() override
Return all the market quotes required for this config.
const vector< string > & smileSpreads() const
string proxySourceCurveId_
const bool requireSwapIndexBases_
const string rootNodeLabel_
const string qualifierLabel_
string shortSwapIndexBase_
vector< string > smileOptionTenors_
Dimension dimension() const
string proxyTargetSwapIndexBase_
boost::optional< ParametricSmileConfiguration > parametricSmileConfiguration_
vector< string > underlyingTenors_
string proxySourceSwapIndexBase_
VolatilityType volatilityType_
BusinessDayConvention businessDayConvention_
const vector< string > & smileUnderlyingTenors() const
Dimension
supported volatility dimensions
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
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 XMLNode * getChildNode(XMLNode *n, const string &name="")
static vector< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Swaption volatility curve configuration classes.
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.
SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant(const std::string &s)
Parse SabrParametricVolatility::ModelVariant.
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
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)
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