23#include <ql/errors.hpp>
31 const string& curveID,
const string& curveDescription,
const string& currency,
32 const vector<QuantLib::ext::shared_ptr<VolatilityConfig>>& volatilityConfig,
const string& equityId,
34 const boost::optional<bool>& preferOutOfTheMoney)
35 :
CurveConfig(curveID, curveDescription), ccy_(currency), volatilityConfig_(volatilityConfig),
36 equityId_(equityId), dayCounter_(dayCounter), calendar_(
calendar), solverConfig_(solverConfig),
37 preferOutOfTheMoney_(preferOutOfTheMoney) {
43 const string& curveID,
const string& curveDescription,
const string& currency,
44 const QuantLib::ext::shared_ptr<VolatilityConfig>& volatilityConfig,
const string& equityId,
46 const boost::optional<bool>& preferOutOfTheMoney)
49 calendar, solverConfig, preferOutOfTheMoney) {}
52 return "EQUITY_OPTION/" + volType +
"/" +
equityId() +
"/" +
ccy_ +
"/";
58 if (QuantLib::ext::dynamic_pointer_cast<QuoteBasedVolatilityConfig>(vc)) {
60 if (
auto c = QuantLib::ext::dynamic_pointer_cast<ConstantVolatilityConfig>(vc)) {
62 }
else if (
auto c = QuantLib::ext::dynamic_pointer_cast<VolatilityCurveConfig>(vc)) {
63 auto qs = c->quotes();
65 }
else if (
auto c = QuantLib::ext::dynamic_pointer_cast<VolatilitySurfaceConfig>(vc)) {
68 string volType = to_string<MarketDatum::QuoteType>(c->quoteType());
69 for (
const pair<string, string>& p : c->quotes()) {
70 if (p.first ==
"*" || p.second ==
"*") {
73 quoteStr =
quoteStem(volType) + p.first +
"/" + p.second;
84 if (
auto p = QuantLib::ext::dynamic_pointer_cast<ProxyVolatilityConfig>(vc)) {
87 if (!p->fxVolatilityCurve().empty())
89 if (!p->correlationCurve().empty())
124 if (dim ==
"ATM" || dim ==
"Smile") {
126 string strikeExtrapolation =
"Flat";
127 string timeExtrapolation =
"Flat";
138 QL_REQUIRE(
strikes.size() == 0,
139 "Dimension ATM, but multiple strikes provided for EquityVolatility " <<
curveID_);
141 vector<string>
quotes(expiries.size());
143 if (expiries.size() == 1 && expiries.front() ==
"*") {
147 for (
auto ex : expiries) {
148 quotes[i] = (stem + ex +
"/ATMF");
153 QuantLib::ext::make_shared<VolatilityCurveConfig>(
quotes, timeExtrapolation, timeExtrapolation));
156 volatilityConfig_.push_back(QuantLib::ext::make_shared<VolatilityStrikeSurfaceConfig>(
157 strikes, expiries,
"Linear",
"Linear",
true, timeExtrapolation, strikeExtrapolation));
160 }
else if (dim ==
"") {
165 QL_FAIL(
"Only ATM and Smile dimensions, or Volatility Config supported for EquityVolatility " <<
curveID_);
209 if (
auto p = QuantLib::ext::dynamic_pointer_cast<ProxyVolatilityConfig>(vc)) {
Base curve configuration.
virtual const vector< string > & quotes()
Return all the market quotes required for this config.
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
Equity volatility structure configuration.
const string quoteStem(const std::string &volType) const
void populateRequiredCurveIds()
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig() const
ReportConfig reportConfig_
OneDimSolverConfig solverConfig() const
EquityVolatilityCurveConfig()
Default constructor.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const string & equityId() const
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
static OneDimSolverConfig defaultSolverConfig()
OneDimSolverConfig solverConfig_
boost::optional< bool > preferOutOfTheMoney_
void fromXML(ore::data::XMLNode *node) override
bool empty() const
Return true if default constructed and not populated i.e. no useful configuration.
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig()
void fromXML(XMLNode *node) override
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
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 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)
static void appendNode(XMLNode *parent, XMLNode *child)
Equity volatility curve configuration classes.
bool parseBool(const string &s)
Convert text to bool.
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities