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

#include <ored/configuration/volatilityconfig.hpp>

+ Inheritance diagram for VolatilityConfigBuilder:
+ Collaboration diagram for VolatilityConfigBuilder:

Public Member Functions

 VolatilityConfigBuilder ()
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void loadVolatiltyConfigs (XMLNode *node)
 
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig ()
 
- 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...
 

Private Attributes

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

Detailed Description

Definition at line 441 of file volatilityconfig.hpp.

Constructor & Destructor Documentation

◆ VolatilityConfigBuilder()

Definition at line 443 of file volatilityconfig.hpp.

443{}

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 561 of file volatilityconfig.cpp.

561 {
562 if (XMLNode* n = XMLUtils::getChildNode(node, "VolatilityConfig"))
564 else
566}
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
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 568 of file volatilityconfig.cpp.

568{ return NULL; }

◆ loadVolatiltyConfigs()

void loadVolatiltyConfigs ( XMLNode node)

Definition at line 499 of file volatilityconfig.cpp.

499 {
500 for (XMLNode* n = XMLUtils::getChildNode(node, "Constant"); n; n = XMLUtils::getNextSibling(n, "Constant")) {
501 auto vc = QuantLib::ext::make_shared<ConstantVolatilityConfig>();
502 vc->fromXML(n);
503 volatilityConfig_.push_back(vc);
504 }
505
506 for (XMLNode* n = XMLUtils::getChildNode(node, "Curve"); n; n = XMLUtils::getNextSibling(n, "Curve")) {
507 auto vc = QuantLib::ext::make_shared<VolatilityCurveConfig>();
508 vc->fromXML(n);
509 volatilityConfig_.push_back(vc);
510 }
511
512 for (XMLNode* n = XMLUtils::getChildNode(node, "DeltaSurface"); n;
513 n = XMLUtils::getNextSibling(n, "DeltaSurface")) {
514 auto vc = QuantLib::ext::make_shared<VolatilityDeltaSurfaceConfig>();
515 vc->fromXML(n);
516 volatilityConfig_.push_back(vc);
517 }
518
519 for (XMLNode* n = XMLUtils::getChildNode(node, "StrikeSurface"); n;
520 n = XMLUtils::getNextSibling(n, "StrikeSurface")) {
521 auto vc = QuantLib::ext::make_shared<VolatilityStrikeSurfaceConfig>();
522 vc->fromXML(n);
523 volatilityConfig_.push_back(vc);
524 }
525
526 for (XMLNode* n = XMLUtils::getChildNode(node, "MoneynessSurface"); n;
527 n = XMLUtils::getNextSibling(n, "MoneynessSurface")) {
528 auto vc = QuantLib::ext::make_shared<VolatilityMoneynessSurfaceConfig>();
529 vc->fromXML(n);
530 volatilityConfig_.push_back(vc);
531 }
532
533 for (XMLNode* n = XMLUtils::getChildNode(node, "ApoFutureSurface"); n;
534 n = XMLUtils::getNextSibling(n, "ApoFutureSurface")) {
535 auto vc = QuantLib::ext::make_shared<VolatilityApoFutureSurfaceConfig>();
536 vc->fromXML(n);
537 volatilityConfig_.push_back(vc);
538 }
539
540 for (XMLNode* n = XMLUtils::getChildNode(node, "ProxySurface"); n;
541 n = XMLUtils::getNextSibling(n, "ProxySurface")) {
542 auto vc = QuantLib::ext::make_shared<ProxyVolatilityConfig>();
543 vc->fromXML(n);
544 volatilityConfig_.push_back(vc);
545 }
546
547 QL_REQUIRE(volatilityConfig_.size() > 0,
548 "VolatilityConfigBuilder expects at least one child node of type: "
549 "Constant, Curve, StrikeSurface, DeltaSurface, MoneynessSurface, ApoFutureSurface, ProxySurface.");
550
551 // sort the volatility configs by priority
552 if (volatilityConfig_.size() > 1)
553 std::sort(volatilityConfig_.begin(), volatilityConfig_.end(),
554 [](const QuantLib::ext::shared_ptr<VolatilityConfig>& a, const QuantLib::ext::shared_ptr<VolatilityConfig>& b) {
555 QL_REQUIRE(a && b,
556 "VolatilityConfigBuilder fails to sort the configs, can not compare a nullptr");
557 return *a < *b;
558 });
559}
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ volatilityConfig()

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

Definition at line 449 of file volatilityconfig.hpp.

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

Member Data Documentation

◆ volatilityConfig_

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

Definition at line 452 of file volatilityconfig.hpp.