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

COM Schwartz Model Parameters. More...

#include <ored/model/commodityschwartzmodeldata.hpp>

+ Collaboration diagram for CommoditySchwartzData:

Public Member Functions

 CommoditySchwartzData (bool driftFreeState=false, QuantLib::ext::shared_ptr< OptimizationMethod > optimizationMethod=QuantLib::ext::make_shared< LevenbergMarquardt >(1E-8, 1E-8, 1E-8), EndCriteria endCriteria=EndCriteria(1000, 500, 1E-8, 1E-8, 1E-8), Constraint constraint=Constraint(), BlackCalibrationHelper::CalibrationErrorType calibrationErrorType=BlackCalibrationHelper::RelativePriceError)
 Default constructor. More...
 
 CommoditySchwartzData (std::string name, std::string currency, CalibrationType calibrationType, bool calibrateSigma, Real sigma, bool calibrateKappa, Real kappa, std::vector< std::string > optionExpiries=std::vector< std::string >(), std::vector< std::string > optionStrikes=std::vector< std::string >(), QuantLib::ext::shared_ptr< OptimizationMethod > optimizationMethod=QuantLib::ext::make_shared< LevenbergMarquardt >(1E-8, 1E-8, 1E-8), EndCriteria endCriteria=EndCriteria(1000, 500, 1E-8, 1E-8, 1E-8), Constraint constraint=Constraint(), BlackCalibrationHelper::CalibrationErrorType calibrationErrorType=BlackCalibrationHelper::RelativePriceError, bool driftFreeState=false)
 Detailed constructor. More...
 
Setters/Getters
std::string & name ()
 
std::string & currency ()
 
CalibrationTypecalibrationType ()
 
boolcalibrateSigma ()
 
ParamTypesigmaParamType ()
 
Real & sigmaValue ()
 
boolcalibrateKappa ()
 
ParamTypekappaParamType ()
 
Real & kappaValue ()
 
std::vector< std::string > & optionExpiries ()
 
std::vector< std::string > & optionStrikes ()
 
booldriftFreeState ()
 
QuantLib::ext::shared_ptr< OptimizationMethod > & optimizationMethod ()
 
EndCriteria & endCriteria ()
 
Constraintconstraint ()
 
BlackCalibrationHelper::CalibrationErrorType calibrationErrorType ()
 
Serialisation
void fromXML (XMLNode *node)
 
XMLNodetoXML (XMLDocument &doc)
 

Operators

std::string name_
 
std::string ccy_
 
CalibrationType calibrationType_ = CalibrationType::None
 
bool calibrateSigma_ = false
 
ParamType sigmaType_ = ParamType::Constant
 
Real sigmaValue_ = 0.0
 
bool calibrateKappa_ = false
 
ParamType kappaType_ = ParamType::Constant
 
Real kappaValue_ = 0.0
 
std::vector< std::string > optionExpiries_
 
std::vector< std::string > optionStrikes_
 
bool driftFreeState_ = false
 
QuantLib::ext::shared_ptr< OptimizationMethodoptimizationMethod_
 
EndCriteria endCriteria_
 
Constraint constraint_
 
BlackCalibrationHelper::CalibrationErrorType calibrationErrorType_ = BlackCalibrationHelper::RelativePriceError
 
bool operator== (const CommoditySchwartzData &rhs)
 
bool operator!= (const CommoditySchwartzData &rhs)
 

Detailed Description

COM Schwartz Model Parameters.

Specification for a COM model component with lognormal forwards in the Cross Asset LGM. This class covers the CommoditySchwartz parametrization.

Definition at line 49 of file commodityschwartzmodeldata.hpp.

Constructor & Destructor Documentation

◆ CommoditySchwartzData() [1/2]

CommoditySchwartzData ( bool  driftFreeState = false,
QuantLib::ext::shared_ptr< OptimizationMethod optimizationMethod = QuantLib::ext::make_shared<LevenbergMarquardt>(1E-8, 1E-8, 1E-8),
EndCriteria  endCriteria = EndCriteria(1000, 500, 1E-8, 1E-8, 1E-8),
Constraint  constraint = Constraint(),
BlackCalibrationHelper::CalibrationErrorType  calibrationErrorType = BlackCalibrationHelper::RelativePriceError 
)

Default constructor.

Definition at line 52 of file commodityschwartzmodeldata.hpp.

BlackCalibrationHelper::CalibrationErrorType calibrationErrorType_
QuantLib::ext::shared_ptr< OptimizationMethod > optimizationMethod_
BlackCalibrationHelper::CalibrationErrorType calibrationErrorType()
QuantLib::ext::shared_ptr< OptimizationMethod > & optimizationMethod()

◆ CommoditySchwartzData() [2/2]

CommoditySchwartzData ( std::string  name,
std::string  currency,
CalibrationType  calibrationType,
bool  calibrateSigma,
Real  sigma,
bool  calibrateKappa,
Real  kappa,
std::vector< std::string >  optionExpiries = std::vector<std::string>(),
std::vector< std::string >  optionStrikes = std::vector<std::string>(),
QuantLib::ext::shared_ptr< OptimizationMethod optimizationMethod = QuantLib::ext::make_shared<LevenbergMarquardt>(1E-8, 1E-8, 1E-8),
EndCriteria  endCriteria = EndCriteria(1000, 500, 1E-8, 1E-8, 1E-8),
Constraint  constraint = Constraint(),
BlackCalibrationHelper::CalibrationErrorType  calibrationErrorType = BlackCalibrationHelper::RelativePriceError,
bool  driftFreeState = false 
)

Detailed constructor.

Definition at line 61 of file commodityschwartzmodeldata.hpp.

std::vector< std::string > & optionStrikes()
std::vector< std::string > & optionExpiries()

Member Function Documentation

◆ name()

std::string & name ( )

Definition at line 80 of file commodityschwartzmodeldata.hpp.

80{ return name_; }

◆ currency()

std::string & currency ( )

Definition at line 81 of file commodityschwartzmodeldata.hpp.

81{ return ccy_; }

◆ calibrationType()

CalibrationType & calibrationType ( )

Definition at line 82 of file commodityschwartzmodeldata.hpp.

82{ return calibrationType_; }

◆ calibrateSigma()

bool & calibrateSigma ( )

Definition at line 83 of file commodityschwartzmodeldata.hpp.

83{ return calibrateSigma_; }

◆ sigmaParamType()

ParamType & sigmaParamType ( )

Definition at line 84 of file commodityschwartzmodeldata.hpp.

84{ return sigmaType_; }

◆ sigmaValue()

Real & sigmaValue ( )

Definition at line 85 of file commodityschwartzmodeldata.hpp.

85{ return sigmaValue_; }

◆ calibrateKappa()

bool & calibrateKappa ( )

Definition at line 86 of file commodityschwartzmodeldata.hpp.

86{ return calibrateKappa_; }

◆ kappaParamType()

ParamType & kappaParamType ( )

Definition at line 87 of file commodityschwartzmodeldata.hpp.

87{ return sigmaType_; }

◆ kappaValue()

Real & kappaValue ( )

Definition at line 88 of file commodityschwartzmodeldata.hpp.

88{ return kappaValue_; }

◆ optionExpiries()

std::vector< std::string > & optionExpiries ( )

Definition at line 89 of file commodityschwartzmodeldata.hpp.

89{ return optionExpiries_; }

◆ optionStrikes()

std::vector< std::string > & optionStrikes ( )

Definition at line 90 of file commodityschwartzmodeldata.hpp.

90{ return optionStrikes_; }

◆ driftFreeState()

bool & driftFreeState ( )

Definition at line 91 of file commodityschwartzmodeldata.hpp.

91{ return driftFreeState_; }

◆ optimizationMethod()

QuantLib::ext::shared_ptr< OptimizationMethod > & optimizationMethod ( )

Definition at line 92 of file commodityschwartzmodeldata.hpp.

92{ return optimizationMethod_; }

◆ endCriteria()

EndCriteria & endCriteria ( )

Definition at line 93 of file commodityschwartzmodeldata.hpp.

93{ return endCriteria_; }

◆ constraint()

Constraint & constraint ( )

Definition at line 94 of file commodityschwartzmodeldata.hpp.

94{ return constraint_; }

◆ calibrationErrorType()

BlackCalibrationHelper::CalibrationErrorType calibrationErrorType ( )

Definition at line 95 of file commodityschwartzmodeldata.hpp.

95{ return calibrationErrorType_; }

◆ fromXML()

void fromXML ( XMLNode node)

Definition at line 39 of file commodityschwartzmodeldata.cpp.

39 {
40 name_ = XMLUtils::getAttribute(node, "name");
41 LOG("Cross-Asset Commodity Name = " << name_);
42
43 ccy_ = XMLUtils::getChildValue(node, "Currency", true);
44 LOG("Cross-Asset Commodity Currency = " << ccy_);
45
46 std::string calibTypeString = XMLUtils::getChildValue(node, "CalibrationType", true);
47 calibrationType_ = parseCalibrationType(calibTypeString);
48 LOG("Cross-Asset Commodity calibration type = " << calibTypeString);
49
50 XMLNode* sigmaNode = XMLUtils::getChildNode(node, "Sigma");
51 calibrateSigma_ = XMLUtils::getChildValueAsBool(sigmaNode, "Calibrate", true);
52 LOG("Cross-Asset Commodity Sigma calibrate = " << calibrateSigma_);
53 sigmaValue_ = XMLUtils::getChildValueAsDouble(sigmaNode, "InitialValue", true);
54 LOG("Cross-Asset Commodity Sigma initial value = " << sigmaValue_);
55
56 XMLNode* kappaNode = XMLUtils::getChildNode(node, "Kappa");
57 calibrateKappa_ = XMLUtils::getChildValueAsBool(kappaNode, "Calibrate", true);
58 LOG("Cross-Asset Commodity Kappa calibrate = " << calibrateKappa_);
59 kappaValue_ = XMLUtils::getChildValueAsDouble(kappaNode, "InitialValue", true);
60 LOG("Cross-Asset Commodity Kappa initial value = " << kappaValue_);
61
62 XMLNode* optionsNode = XMLUtils::getChildNode(node, "CalibrationOptions");
63 if (optionsNode) {
64 optionExpiries_ = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Expiries", true);
65 optionStrikes_ = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Strikes", false);
66 if (optionStrikes_.size() > 0) {
67 QL_REQUIRE(optionExpiries_.size() == optionStrikes_.size(),
68 "size mismatch in commodity option expiries/strike for name " << name_);
69 } else // default ATMF
70 optionStrikes_.resize(optionExpiries_.size(), "ATMF");
71 }
72
73 driftFreeState_ = XMLUtils::getChildValueAsBool(node, "DriftFreeState", false);
74}
static string getAttribute(XMLNode *node, const string &attrName)
Definition: xmlutils.cpp:419
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static vector< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:342
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
CalibrationType parseCalibrationType(const string &s)
Convert calibration type string into enumerated class value.
Definition: irmodeldata.cpp:47
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc)

Definition at line 76 of file commodityschwartzmodeldata.cpp.

76 {
77
78 XMLNode* node = doc.allocNode("CommoditySchwartz");
79 XMLUtils::addAttribute(doc, node, "name", name_);
80
81 XMLUtils::addChild(doc, node, "Currency", ccy_);
82 XMLUtils::addGenericChild(doc, node, "CalibrationType", calibrationType_);
83
84 XMLNode* sigmaNode = XMLUtils::addChild(doc, node, "Sigma");
85 XMLUtils::addChild(doc, sigmaNode, "Calibrate", calibrateSigma_);
86 XMLUtils::addChild(doc, sigmaNode, "InitialValue", sigmaValue_);
87
88 XMLNode* kappaNode = XMLUtils::addChild(doc, node, "Kappa");
89 XMLUtils::addChild(doc, kappaNode, "Calibrate", calibrateKappa_);
90 XMLUtils::addChild(doc, kappaNode, "InitialValue", kappaValue_);
91
92 XMLNode* calibrationOptionsNode = XMLUtils::addChild(doc, node, "CalibrationOptions");
93 XMLUtils::addGenericChildAsList(doc, calibrationOptionsNode, "Expiries", optionExpiries_);
94 XMLUtils::addGenericChildAsList(doc, calibrationOptionsNode, "Strikes", optionStrikes_);
95
96 XMLUtils::addChild(doc, node, "DriftFreeState", driftFreeState_);
97
98 return node;
99}
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
Definition: xmlutils.cpp:412
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
Definition: xmlutils.hpp:144
static void addGenericChild(XMLDocument &doc, XMLNode *n, const char *name, const T &value)
Adds <Name>p1,p2,p3</Name>
Definition: xmlutils.hpp:137
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const CommoditySchwartzData rhs)

Definition at line 26 of file commodityschwartzmodeldata.cpp.

26 {
27
28 if (name_ != rhs.name_ || ccy_ != rhs.ccy_ || calibrationType_ != rhs.calibrationType_ ||
29 calibrateSigma_ != rhs.calibrateSigma_ || sigmaType_ != rhs.sigmaType_ || sigmaValue_ != rhs.sigmaValue_ ||
30 calibrateKappa_ != rhs.calibrateKappa_ || kappaType_ != rhs.kappaType_ || kappaValue_ != rhs.kappaValue_ ||
31 optionExpiries_ != rhs.optionExpiries_ || optionStrikes_ != rhs.optionStrikes_ || driftFreeState_ == rhs.driftFreeState_) {
32 return false;
33 }
34 return true;
35}

◆ operator!=()

Definition at line 37 of file commodityschwartzmodeldata.cpp.

37{ return !(*this == rhs); }

Member Data Documentation

◆ name_

std::string name_
private

Definition at line 111 of file commodityschwartzmodeldata.hpp.

◆ ccy_

std::string ccy_
private

Definition at line 112 of file commodityschwartzmodeldata.hpp.

◆ calibrationType_

CalibrationType calibrationType_ = CalibrationType::None
private

Definition at line 113 of file commodityschwartzmodeldata.hpp.

◆ calibrateSigma_

bool calibrateSigma_ = false
private

Definition at line 114 of file commodityschwartzmodeldata.hpp.

◆ sigmaType_

ParamType sigmaType_ = ParamType::Constant
private

Definition at line 115 of file commodityschwartzmodeldata.hpp.

◆ sigmaValue_

Real sigmaValue_ = 0.0
private

Definition at line 116 of file commodityschwartzmodeldata.hpp.

◆ calibrateKappa_

bool calibrateKappa_ = false
private

Definition at line 117 of file commodityschwartzmodeldata.hpp.

◆ kappaType_

ParamType kappaType_ = ParamType::Constant
private

Definition at line 118 of file commodityschwartzmodeldata.hpp.

◆ kappaValue_

Real kappaValue_ = 0.0
private

Definition at line 119 of file commodityschwartzmodeldata.hpp.

◆ optionExpiries_

std::vector<std::string> optionExpiries_
private

Definition at line 120 of file commodityschwartzmodeldata.hpp.

◆ optionStrikes_

std::vector<std::string> optionStrikes_
private

Definition at line 121 of file commodityschwartzmodeldata.hpp.

◆ driftFreeState_

bool driftFreeState_ = false
private

Definition at line 122 of file commodityschwartzmodeldata.hpp.

◆ optimizationMethod_

QuantLib::ext::shared_ptr<OptimizationMethod> optimizationMethod_
private

Definition at line 123 of file commodityschwartzmodeldata.hpp.

◆ endCriteria_

EndCriteria endCriteria_
private

Definition at line 124 of file commodityschwartzmodeldata.hpp.

◆ constraint_

Constraint constraint_
private

Definition at line 125 of file commodityschwartzmodeldata.hpp.

◆ calibrationErrorType_

BlackCalibrationHelper::CalibrationErrorType calibrationErrorType_ = BlackCalibrationHelper::RelativePriceError
private

Definition at line 126 of file commodityschwartzmodeldata.hpp.