Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
EquityVolatilityCurveConfig Class Reference

Equity volatility structure configuration. More...

#include <ored/configuration/equityvolcurveconfig.hpp>

+ Inheritance diagram for EquityVolatilityCurveConfig:
+ Collaboration diagram for EquityVolatilityCurveConfig:

Public Member Functions

Constructors/Destructors
 EquityVolatilityCurveConfig ()
 Default constructor. More...
 
 EquityVolatilityCurveConfig (const string &curveID, const string &curveDescription, const string &currency, const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > &volatilityConfig, const string &equityId=string(), const string &dayCounter="A365", const string &calendar="NullCalendar", const OneDimSolverConfig &solverConfig=OneDimSolverConfig(), const boost::optional< bool > &preferOutOfTheMoney=boost::none)
 Detailed constructor. More...
 
 EquityVolatilityCurveConfig (const string &curveID, const string &curveDescription, const string &currency, const QuantLib::ext::shared_ptr< VolatilityConfig > &volatilityConfig, const string &equityId=string(), const string &dayCounter="A365", const string &calendar="NullCalendar", const OneDimSolverConfig &solverConfig=OneDimSolverConfig(), const boost::optional< bool > &preferOutOfTheMoney=boost::none)
 
Serialisation
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
Inspectors
const string & equityId () const
 
const string & ccy () const
 
const string & dayCounter () const
 
const string & calendar () const
 
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig () const
 
const string quoteStem (const std::string &volType) const
 
void populateQuotes ()
 
bool isProxySurface ()
 
OneDimSolverConfig solverConfig () const
 
const boost::optional< bool > & preferOutOfTheMoney () const
 
const ReportConfigreportConfig () const
 
- Public Member Functions inherited from CurveConfig
 CurveConfig (const string &curveID, const string &curveDescription, const vector< string > &quotes=vector< string >())
 Detailed constructor. More...
 
 CurveConfig ()
 Default constructor. More...
 
const string & curveID () const
 
const string & curveDescription () const
 
const set< string > & requiredCurveIds (const CurveSpec::CurveType &curveType) const
 
const map< CurveSpec::CurveType, set< string > > & requiredCurveIds () const
 
string & curveID ()
 
string & curveDescription ()
 
set< string > & requiredCurveIds (const CurveSpec::CurveType &curveType)
 
map< CurveSpec::CurveType, set< string > > & requiredCurveIds ()
 
virtual const vector< string > & quotes ()
 Return all the market quotes required for this config. More...
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Setters

string ccy_
 
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
 
string equityId_
 
string dayCounter_
 
string calendar_
 
OneDimSolverConfig solverConfig_
 
boost::optional< boolpreferOutOfTheMoney_
 
ReportConfig reportConfig_
 
string & ccy ()
 
string & dayCounter ()
 
void populateRequiredCurveIds ()
 
static OneDimSolverConfig defaultSolverConfig ()
 

Additional Inherited Members

- Protected Attributes inherited from CurveConfig
string curveID_
 
string curveDescription_
 
vector< string > quotes_
 
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
 

Detailed Description

Equity volatility structure configuration.

Definition at line 47 of file equityvolcurveconfig.hpp.

Constructor & Destructor Documentation

◆ EquityVolatilityCurveConfig() [1/3]

Default constructor.

Definition at line 52 of file equityvolcurveconfig.hpp.

52{}

◆ EquityVolatilityCurveConfig() [2/3]

EquityVolatilityCurveConfig ( const string &  curveID,
const string &  curveDescription,
const string &  currency,
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > &  volatilityConfig,
const string &  equityId = string(),
const string &  dayCounter = "A365",
const string &  calendar = "NullCalendar",
const OneDimSolverConfig solverConfig = OneDimSolverConfig(),
const boost::optional< bool > &  preferOutOfTheMoney = boost::none 
)

Detailed constructor.

Definition at line 30 of file equityvolcurveconfig.cpp.

40}
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
CurveConfig()
Default constructor.
Definition: curveconfig.hpp:49
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig() const
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
const boost::optional< bool > & preferOutOfTheMoney() const
+ Here is the call graph for this function:

◆ EquityVolatilityCurveConfig() [3/3]

EquityVolatilityCurveConfig ( const string &  curveID,
const string &  curveDescription,
const string &  currency,
const QuantLib::ext::shared_ptr< VolatilityConfig > &  volatilityConfig,
const string &  equityId = string(),
const string &  dayCounter = "A365",
const string &  calendar = "NullCalendar",
const OneDimSolverConfig solverConfig = OneDimSolverConfig(),
const boost::optional< bool > &  preferOutOfTheMoney = boost::none 
)

Definition at line 42 of file equityvolcurveconfig.cpp.

48 std::vector<QuantLib::ext::shared_ptr<VolatilityConfig>>{volatilityConfig}, equityId, dayCounter,
+ Here is the call graph for this function:

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 95 of file equityvolcurveconfig.cpp.

95 {
96 XMLUtils::checkNode(node, "EquityVolatility");
97
98 curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
99 curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
100 equityId_ = XMLUtils::getChildValue(node, "EquityId", false);
101 ccy_ = XMLUtils::getChildValue(node, "Currency", true);
102
103 calendar_ = XMLUtils::getChildValue(node, "Calendar", false);
104
105 XMLNode* n;
106 dayCounter_ = "A365";
107 if ((n = XMLUtils::getChildNode(node, "DayCounter")))
109
110 solverConfig_ = OneDimSolverConfig();
111 if (XMLNode* n = XMLUtils::getChildNode(node, "OneDimSolverConfig")) {
113 }
114
115 preferOutOfTheMoney_ = boost::none;
116 if (XMLNode* n = XMLUtils::getChildNode(node, "PreferOutOfTheMoney")) {
118 }
119
120 // In order to remain backward compatible, we first check for a dimension node
121 // If this is present we read the nodes as before but create volatilityConfigs from the inputs
122 // If no dimension nodes then we expect VolatilityConfig nodes - this is the preferred configuration
123 string dim = XMLUtils::getChildValue(node, "Dimension", false);
124 if (dim == "ATM" || dim == "Smile") {
125 vector<string> expiries = XMLUtils::getChildrenValuesAsStrings(node, "Expiries", true);
126 string strikeExtrapolation = "Flat";
127 string timeExtrapolation = "Flat";
128 XMLNode* timeNode = XMLUtils::getChildNode(node, "TimeExtrapolation");
129 if (timeNode) {
130 timeExtrapolation = XMLUtils::getChildValue(node, "TimeExtrapolation", true);
131 }
132 XMLNode* strikeNode = XMLUtils::getChildNode(node, "StrikeExtrapolation");
133 if (strikeNode) {
134 strikeExtrapolation = XMLUtils::getChildValue(node, "StrikeExtrapolation", true);
135 }
136 vector<string> strikes = XMLUtils::getChildrenValuesAsStrings(node, "Strikes", false);
137 if (dim == "ATM") {
138 QL_REQUIRE(strikes.size() == 0,
139 "Dimension ATM, but multiple strikes provided for EquityVolatility " << curveID_);
140 // if ATM create VolatilityCurveConfig which requires quotes to be provided
141 vector<string> quotes(expiries.size());
142 string stem = quoteStem("RATE_LNVOL");
143 if (expiries.size() == 1 && expiries.front() == "*") {
144 quotes[0] = (stem + "*");
145 } else {
146 Size i = 0;
147 for (auto ex : expiries) {
148 quotes[i] = (stem + ex + "/ATMF");
149 i++;
150 }
151 }
152 volatilityConfig_.push_back(
153 QuantLib::ext::make_shared<VolatilityCurveConfig>(quotes, timeExtrapolation, timeExtrapolation));
154 } else {
155 // if Smile create VolatilityStrikeSurfaceConfig
156 volatilityConfig_.push_back(QuantLib::ext::make_shared<VolatilityStrikeSurfaceConfig>(
157 strikes, expiries, "Linear", "Linear", true, timeExtrapolation, strikeExtrapolation));
158 }
159
160 } else if (dim == "") {
161 VolatilityConfigBuilder vcb;
162 vcb.fromXML(node);
163 volatilityConfig_ = vcb.volatilityConfig();
164 } else {
165 QL_FAIL("Only ATM and Smile dimensions, or Volatility Config supported for EquityVolatility " << curveID_);
166 }
167
168 if (auto tmp = XMLUtils::getChildNode(node, "Report")) {
170 }
171
174}
virtual const vector< string > & quotes()
Return all the market quotes required for this config.
Definition: curveconfig.hpp:69
const string quoteStem(const std::string &volType) const
void fromXML(ore::data::XMLNode *node) override
void fromXML(XMLNode *node) override
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static vector< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:342
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
vector< Real > strikes
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 176 of file equityvolcurveconfig.cpp.

176 {
177
178 XMLNode* node = doc.allocNode("EquityVolatility");
179
180 XMLUtils::addChild(doc, node, "CurveId", curveID_);
181 XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
182 XMLUtils::addChild(doc, node, "EquityId", equityId_);
183 XMLUtils::addChild(doc, node, "Currency", ccy_);
184 XMLUtils::addChild(doc, node, "DayCounter", dayCounter_);
185
186 XMLNode* vnode = doc.allocNode("VolatilityConfig");
187 for (auto vc : volatilityConfig_) {
188 XMLNode* n = vc->toXML(doc);
189 XMLUtils::appendNode(vnode, n);
190 }
191 XMLUtils::appendNode(node, vnode);
192
193 if (calendar_ != "NullCalendar")
194 XMLUtils::addChild(doc, node, "Calendar", calendar_);
195
196 if (!solverConfig_.empty())
198
200 XMLUtils::addChild(doc, node, "PreferOutOfTheMoney", *preferOutOfTheMoney_);
201
203
204 return node;
205}
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
XMLNode * toXML(XMLDocument &doc) const override
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:

◆ equityId()

const string & equityId ( ) const

Definition at line 76 of file equityvolcurveconfig.hpp.

76{ return equityId_.empty() ? curveID_ : equityId_; }
+ Here is the caller graph for this function:

◆ ccy() [1/2]

const string & ccy ( ) const

Definition at line 77 of file equityvolcurveconfig.hpp.

77{ return parseCurrencyWithMinors(ccy_).code(); }
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:310
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dayCounter() [1/2]

const string & dayCounter ( ) const

Definition at line 78 of file equityvolcurveconfig.hpp.

78{ return dayCounter_; }
+ Here is the caller graph for this function:

◆ calendar()

const string & calendar ( ) const

Definition at line 79 of file equityvolcurveconfig.hpp.

79{ return calendar_; }
+ Here is the caller graph for this function:

◆ volatilityConfig()

const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig ( ) const

Definition at line 80 of file equityvolcurveconfig.hpp.

80{ return volatilityConfig_; }
+ Here is the caller graph for this function:

◆ quoteStem()

const string quoteStem ( const std::string &  volType) const

Definition at line 51 of file equityvolcurveconfig.cpp.

51 {
52 return "EQUITY_OPTION/" + volType + "/" + equityId() + "/" + ccy_ + "/";
53}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuotes()

void populateQuotes ( )

Definition at line 55 of file equityvolcurveconfig.cpp.

55 {
56 // add quotes from all the volatility configs
57 for (auto vc : volatilityConfig_) {
58 if (QuantLib::ext::dynamic_pointer_cast<QuoteBasedVolatilityConfig>(vc)) {
59 // The quotes depend on the type of volatility structure that has been configured.
60 if (auto c = QuantLib::ext::dynamic_pointer_cast<ConstantVolatilityConfig>(vc)) {
61 quotes_.push_back(c->quote());
62 } else if (auto c = QuantLib::ext::dynamic_pointer_cast<VolatilityCurveConfig>(vc)) {
63 auto qs = c->quotes();
64 quotes_.insert(quotes_.end(), qs.begin(), qs.end());
65 } else if (auto c = QuantLib::ext::dynamic_pointer_cast<VolatilitySurfaceConfig>(vc)) {
66 // Clear the quotes_ if necessary and populate with surface quotes
67 string quoteStr;
68 string volType = to_string<MarketDatum::QuoteType>(c->quoteType());
69 for (const pair<string, string>& p : c->quotes()) {
70 if (p.first == "*" || p.second == "*") {
71 quoteStr = quoteStem(volType) + "*";
72 } else {
73 quoteStr = quoteStem(volType) + p.first + "/" + p.second;
74 }
75 quotes_.push_back(quoteStr);
76 }
77 }
78 }
79 }
80}
vector< string > quotes_
Definition: curveconfig.hpp:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProxySurface()

bool isProxySurface ( )

Definition at line 207 of file equityvolcurveconfig.cpp.

207 {
208 for (auto vc : volatilityConfig_) {
209 if (auto p = QuantLib::ext::dynamic_pointer_cast<ProxyVolatilityConfig>(vc)) {
210 return true;
211 }
212 }
213 return false;
214}

◆ solverConfig()

OneDimSolverConfig solverConfig ( ) const

Definition at line 216 of file equityvolcurveconfig.cpp.

216 {
218}
static OneDimSolverConfig defaultSolverConfig()
+ Here is the call graph for this function:

◆ preferOutOfTheMoney()

const boost::optional< bool > & preferOutOfTheMoney ( ) const

Definition at line 85 of file equityvolcurveconfig.hpp.

85 {
87 }

◆ reportConfig()

const ReportConfig & reportConfig ( ) const

Definition at line 88 of file equityvolcurveconfig.hpp.

88{ return reportConfig_; }
+ Here is the caller graph for this function:

◆ ccy() [2/2]

string & ccy ( )

Definition at line 93 of file equityvolcurveconfig.hpp.

93{ return ccy_; }

◆ dayCounter() [2/2]

string & dayCounter ( )

Definition at line 94 of file equityvolcurveconfig.hpp.

94{ return dayCounter_; }

◆ populateRequiredCurveIds()

void populateRequiredCurveIds ( )
private

Definition at line 82 of file equityvolcurveconfig.cpp.

82 {
83 for (auto vc : volatilityConfig_) {
84 if (auto p = QuantLib::ext::dynamic_pointer_cast<ProxyVolatilityConfig>(vc)) {
85 requiredCurveIds_[CurveSpec::CurveType::Equity].insert(p->proxyVolatilityCurve());
86 requiredCurveIds_[CurveSpec::CurveType::EquityVolatility].insert(p->proxyVolatilityCurve());
87 if (!p->fxVolatilityCurve().empty())
88 requiredCurveIds_[CurveSpec::CurveType::FXVolatility].insert(p->fxVolatilityCurve());
89 if (!p->correlationCurve().empty())
90 requiredCurveIds_[CurveSpec::CurveType::Correlation].insert(p->correlationCurve());
91 }
92 }
93}
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
Definition: curveconfig.hpp:75
+ Here is the caller graph for this function:

◆ defaultSolverConfig()

OneDimSolverConfig defaultSolverConfig ( )
staticprivate

Definition at line 220 of file equityvolcurveconfig.cpp.

220 {
221
222 // Backward compatible with code that existed before EquityVolatilityCurveConfig
223 // accepted a solver configuration.
224 static OneDimSolverConfig res(100, 0.2, 0.0001, 0.01, 0.0001);
225
226 return res;
227}
+ Here is the caller graph for this function:

Member Data Documentation

◆ ccy_

string ccy_
private

Definition at line 100 of file equityvolcurveconfig.hpp.

◆ volatilityConfig_

std::vector<QuantLib::ext::shared_ptr<VolatilityConfig> > volatilityConfig_
private

Definition at line 101 of file equityvolcurveconfig.hpp.

◆ equityId_

string equityId_
private

Definition at line 102 of file equityvolcurveconfig.hpp.

◆ dayCounter_

string dayCounter_
private

Definition at line 103 of file equityvolcurveconfig.hpp.

◆ calendar_

string calendar_
private

Definition at line 104 of file equityvolcurveconfig.hpp.

◆ solverConfig_

OneDimSolverConfig solverConfig_
private

Definition at line 105 of file equityvolcurveconfig.hpp.

◆ preferOutOfTheMoney_

boost::optional<bool> preferOutOfTheMoney_
private

Definition at line 106 of file equityvolcurveconfig.hpp.

◆ reportConfig_

ReportConfig reportConfig_
private

Definition at line 107 of file equityvolcurveconfig.hpp.