Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CommodityVolatilityConfig Class Reference

Commodity volatility configuration. More...

#include <ored/configuration/commodityvolcurveconfig.hpp>

+ Inheritance diagram for CommodityVolatilityConfig:
+ Collaboration diagram for CommodityVolatilityConfig:

Public Member Functions

 CommodityVolatilityConfig ()
 Default constructor. More...
 
 CommodityVolatilityConfig (const std::string &curveId, const std::string &curveDescription, const std::string &currency, const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > &volatilityConfig, const std::string &dayCounter="A365", const std::string &calendar="NullCalendar", const std::string &futureConventionsId="", QuantLib::Natural optionExpiryRollDays=0, const std::string &priceCurveId="", const std::string &yieldCurveId="", const std::string &quoteSuffix="", const OneDimSolverConfig &solverConfig=OneDimSolverConfig(), const boost::optional< bool > &preferOutOfTheMoney=boost::none)
 Explicit constructor. More...
 
Inspectors
const std::string & currency () const
 
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig () const
 
const std::string & dayCounter () const
 
const std::string & calendar () const
 
const std::string & futureConventionsId () const
 
QuantLib::Natural optionExpiryRollDays () const
 
const std::string & priceCurveId () const
 
const std::string & yieldCurveId () const
 
const std::string & quoteSuffix () const
 
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...
 

Serialisation

std::string currency_
 
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
 
std::string dayCounter_
 
std::string calendar_
 
std::string futureConventionsId_
 
QuantLib::Natural optionExpiryRollDays_
 
std::string priceCurveId_
 
std::string yieldCurveId_
 
std::string quoteSuffix_
 
OneDimSolverConfig solverConfig_
 
boost::optional< boolpreferOutOfTheMoney_
 
ReportConfig reportConfig_
 
void fromXML (XMLNode *node) override
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void populateRequiredCurveIds ()
 
void populateQuotes ()
 Populate CurveConfig::quotes_ with the required quotes. More...
 
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

Commodity volatility configuration.

Definition at line 38 of file commodityvolcurveconfig.hpp.

Constructor & Destructor Documentation

◆ CommodityVolatilityConfig() [1/2]

Default constructor.

Definition at line 31 of file commodityvolcurveconfig.cpp.

◆ CommodityVolatilityConfig() [2/2]

CommodityVolatilityConfig ( const std::string &  curveId,
const std::string &  curveDescription,
const std::string &  currency,
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > &  volatilityConfig,
const std::string &  dayCounter = "A365",
const std::string &  calendar = "NullCalendar",
const std::string &  futureConventionsId = "",
QuantLib::Natural  optionExpiryRollDays = 0,
const std::string &  priceCurveId = "",
const std::string &  yieldCurveId = "",
const std::string &  quoteSuffix = "",
const OneDimSolverConfig solverConfig = OneDimSolverConfig(),
const boost::optional< bool > &  preferOutOfTheMoney = boost::none 
)

Explicit constructor.

Definition at line 34 of file commodityvolcurveconfig.cpp.

46}
void populateQuotes()
Populate CurveConfig::quotes_ with the required quotes.
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig() const
const std::string & futureConventionsId() const
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
const boost::optional< bool > & preferOutOfTheMoney() const
const string & curveDescription() const
Definition: curveconfig.hpp:55
CurveConfig()
Default constructor.
Definition: curveconfig.hpp:49
+ Here is the call graph for this function:

Member Function Documentation

◆ currency()

const string & currency ( ) const

Definition at line 69 of file commodityvolcurveconfig.cpp.

69{ return currency_; }
+ Here is the caller graph for this function:

◆ volatilityConfig()

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

Definition at line 73 of file commodityvolcurveconfig.cpp.

73 {
74 return volatilityConfig_;
75}
+ Here is the caller graph for this function:

◆ dayCounter()

const string & dayCounter ( ) const

Definition at line 71 of file commodityvolcurveconfig.cpp.

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

◆ calendar()

const string & calendar ( ) const

Definition at line 77 of file commodityvolcurveconfig.cpp.

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

◆ futureConventionsId()

const string & futureConventionsId ( ) const

Definition at line 79 of file commodityvolcurveconfig.cpp.

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

◆ optionExpiryRollDays()

Natural optionExpiryRollDays ( ) const

Definition at line 81 of file commodityvolcurveconfig.cpp.

81{ return optionExpiryRollDays_; }
+ Here is the caller graph for this function:

◆ priceCurveId()

const string & priceCurveId ( ) const

Definition at line 83 of file commodityvolcurveconfig.cpp.

83{ return priceCurveId_; }
+ Here is the caller graph for this function:

◆ yieldCurveId()

const string & yieldCurveId ( ) const

Definition at line 85 of file commodityvolcurveconfig.cpp.

85{ return yieldCurveId_; }
+ Here is the caller graph for this function:

◆ quoteSuffix()

const string & quoteSuffix ( ) const

Definition at line 87 of file commodityvolcurveconfig.cpp.

87{ return quoteSuffix_; }

◆ solverConfig()

OneDimSolverConfig solverConfig ( ) const

Definition at line 93 of file commodityvolcurveconfig.cpp.

93 {
95}
static OneDimSolverConfig defaultSolverConfig()
bool empty() const
Return true if default constructed and not populated i.e. no useful configuration.
+ Here is the call graph for this function:

◆ preferOutOfTheMoney()

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

Definition at line 89 of file commodityvolcurveconfig.cpp.

89 {
91}

◆ reportConfig()

const ReportConfig & reportConfig ( ) const

Definition at line 67 of file commodityvolcurveconfig.hpp.

+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 106 of file commodityvolcurveconfig.cpp.

106 {
107
108 XMLUtils::checkNode(node, "CommodityVolatility");
109
110 curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
111 curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
112 currency_ = XMLUtils::getChildValue(node, "Currency", true);
113
114 VolatilityConfigBuilder vcb;
115 vcb.fromXML(node);
116 volatilityConfig_ = vcb.volatilityConfig();
117
118 dayCounter_ = "A365";
119 if (XMLNode* n = XMLUtils::getChildNode(node, "DayCounter"))
121
122 calendar_ = "NullCalendar";
123 if (XMLNode* n = XMLUtils::getChildNode(node, "Calendar"))
125
126 futureConventionsId_ = XMLUtils::getChildValue(node, "FutureConventions", false);
127
129 if (XMLNode* n = XMLUtils::getChildNode(node, "OptionExpiryRollDays"))
131
132 priceCurveId_ = XMLUtils::getChildValue(node, "PriceCurveId", false);
133 yieldCurveId_ = XMLUtils::getChildValue(node, "YieldCurveId", false);
134
135 quoteSuffix_ = XMLUtils::getChildValue(node, "QuoteSuffix", false);
136
137 solverConfig_ = OneDimSolverConfig();
138 if (XMLNode* n = XMLUtils::getChildNode(node, "OneDimSolverConfig")) {
140 }
141
142 preferOutOfTheMoney_ = boost::none;
143 if (XMLNode* n = XMLUtils::getChildNode(node, "PreferOutOfTheMoney")) {
145 }
146
147 if(auto tmp = XMLUtils::getChildNode(node, "Report")){
149 }
152}
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
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 154 of file commodityvolcurveconfig.cpp.

154 {
155
156 XMLNode* node = doc.allocNode("CommodityVolatility");
157
158 XMLUtils::addChild(doc, node, "CurveId", curveID_);
159 XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
160 XMLUtils::addChild(doc, node, "Currency", currency_);
161
162 XMLNode* vnode = doc.allocNode("VolatilityConfig");
163 for (auto vc : volatilityConfig_) {
164 XMLNode* n = vc->toXML(doc);
165 XMLUtils::appendNode(vnode, n);
166 }
167 XMLUtils::appendNode(node, vnode);
168
169 XMLUtils::addChild(doc, node, "DayCounter", dayCounter_);
170 XMLUtils::addChild(doc, node, "Calendar", calendar_);
171 if (!futureConventionsId_.empty())
172 XMLUtils::addChild(doc, node, "FutureConventions", futureConventionsId_);
173 XMLUtils::addChild(doc, node, "OptionExpiryRollDays", static_cast<int>(optionExpiryRollDays_));
174 if (!priceCurveId_.empty())
175 XMLUtils::addChild(doc, node, "PriceCurveId", priceCurveId_);
176 if (!yieldCurveId_.empty())
177 XMLUtils::addChild(doc, node, "YieldCurveId", yieldCurveId_);
178 if (!quoteSuffix_.empty())
179 XMLUtils::addChild(doc, node, "QuoteSuffix", quoteSuffix_);
180 if (!solverConfig_.empty())
183 XMLUtils::addChild(doc, node, "PreferOutOfTheMoney", *preferOutOfTheMoney_);
185 return node;
186}
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
XMLNode * toXML(XMLDocument &doc) const override
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
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:

◆ populateRequiredCurveIds()

void populateRequiredCurveIds ( )
private

Definition at line 48 of file commodityvolcurveconfig.cpp.

48 {
49 if (!priceCurveId().empty())
51 if (!yieldCurveId().empty())
53 for (auto vc : volatilityConfig()) {
54 if (auto vapo = QuantLib::ext::dynamic_pointer_cast<VolatilityApoFutureSurfaceConfig>(vc)) {
56 parseCurveSpec(vapo->baseVolatilityId())->curveConfigID());
57 }
58 if (auto p = QuantLib::ext::dynamic_pointer_cast<ProxyVolatilityConfig>(vc)) {
59 requiredCurveIds_[CurveSpec::CurveType::Commodity].insert(p->proxyVolatilityCurve());
60 requiredCurveIds_[CurveSpec::CurveType::CommodityVolatility].insert(p->proxyVolatilityCurve());
61 if (!p->fxVolatilityCurve().empty())
62 requiredCurveIds_[CurveSpec::CurveType::FXVolatility].insert(p->fxVolatilityCurve());
63 if (!p->correlationCurve().empty())
64 requiredCurveIds_[CurveSpec::CurveType::Correlation].insert(p->correlationCurve());
65 }
66 }
67}
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
Definition: curveconfig.hpp:75
QuantLib::ext::shared_ptr< CurveSpec > parseCurveSpec(const string &s)
function to convert a string into a curve spec
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuotes()

void populateQuotes ( )
private

Populate CurveConfig::quotes_ with the required quotes.

Definition at line 188 of file commodityvolcurveconfig.cpp.

188 {
189
190 for (auto config : volatilityConfig_) {
191 // The quotes depend on the type of volatility structure that has been configured.
192 if (auto vc = QuantLib::ext::dynamic_pointer_cast<ConstantVolatilityConfig>(config)) {
193 quotes_.push_back(vc->quote());
194 } else if (auto vc = QuantLib::ext::dynamic_pointer_cast<VolatilityCurveConfig>(config)) {
195 auto qs = vc->quotes();
196 quotes_.insert(quotes_.end(), qs.begin(), qs.end());
197 } else if (auto vc = QuantLib::ext::dynamic_pointer_cast<VolatilitySurfaceConfig>(config)) {
198 string quoteType = to_string(vc->quoteType());
199 string stem = "COMMODITY_OPTION/" + quoteType + "/" + curveID_ + "/" + currency_ + "/";
200 for (const pair<string, string>& p : vc->quotes()) {
201 string q = stem + p.first + "/" + p.second;
202 if (!quoteSuffix_.empty())
203 q += "/" + quoteSuffix_;
204 quotes_.push_back(q);
205 }
206 }
207 }
208}
vector< string > quotes_
Definition: curveconfig.hpp:74
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ defaultSolverConfig()

OneDimSolverConfig defaultSolverConfig ( )
staticprivate

Definition at line 97 of file commodityvolcurveconfig.cpp.

97 {
98
99 // Some "reasonable" defaults for commodity volatility searches.
100 // Max eval of 100. Initial guess of 35%. Search between 1 bp and 200%.
101 static OneDimSolverConfig res(100, 0.35, 0.0001, std::make_pair(0.0001, 2.0));
102
103 return res;
104}
+ Here is the caller graph for this function:

Member Data Documentation

◆ currency_

std::string currency_
private

Definition at line 79 of file commodityvolcurveconfig.hpp.

◆ volatilityConfig_

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

Definition at line 80 of file commodityvolcurveconfig.hpp.

◆ dayCounter_

std::string dayCounter_
private

Definition at line 81 of file commodityvolcurveconfig.hpp.

◆ calendar_

std::string calendar_
private

Definition at line 82 of file commodityvolcurveconfig.hpp.

◆ futureConventionsId_

std::string futureConventionsId_
private

Definition at line 83 of file commodityvolcurveconfig.hpp.

◆ optionExpiryRollDays_

QuantLib::Natural optionExpiryRollDays_
private

Definition at line 84 of file commodityvolcurveconfig.hpp.

◆ priceCurveId_

std::string priceCurveId_
private

Definition at line 85 of file commodityvolcurveconfig.hpp.

◆ yieldCurveId_

std::string yieldCurveId_
private

Definition at line 86 of file commodityvolcurveconfig.hpp.

◆ quoteSuffix_

std::string quoteSuffix_
private

Definition at line 87 of file commodityvolcurveconfig.hpp.

◆ solverConfig_

OneDimSolverConfig solverConfig_
private

Definition at line 88 of file commodityvolcurveconfig.hpp.

◆ preferOutOfTheMoney_

boost::optional<bool> preferOutOfTheMoney_
private

Definition at line 89 of file commodityvolcurveconfig.hpp.

◆ reportConfig_

ReportConfig reportConfig_
private

Definition at line 90 of file commodityvolcurveconfig.hpp.