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

#include <orea/simm/simmcalibration.hpp>

+ Inheritance diagram for SimmCalibration:
+ Collaboration diagram for SimmCalibration:

Classes

class  Amount
 
class  RiskClassData
 

Public Types

typedef std::map< std::tuple< std::string, std::string, std::string >, std::string > Amounts
 
typedef std::map< std::tuple< std::string, std::string, std::string >, std::set< std::string > > CurrencyLists
 

Public Member Functions

 SimmCalibration ()
 
 SimmCalibration (ore::data::XMLNode *node)
 
const std::string & version () const
 
const std::vector< std::string > & versionNames () const
 
const std::vector< std::pair< std::string, std::string > > & additionalFields () const
 
- 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)
 
std::string toXMLString () const
 

Serialisation

std::string id_
 
std::vector< std::string > versionNames_
 
std::vector< std::pair< std::string, std::string > > additionalFields_
 
std::map< SimmConfiguration::RiskClass, QuantLib::ext::shared_ptr< RiskClassData > > riskClassData_
 
Amounts riskClassCorrelations_
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void fromXML (ore::data::XMLNode *node) override
 
const std::map< SimmConfiguration::RiskClass, QuantLib::ext::shared_ptr< RiskClassData > > & riskClassData () const
 
const AmountsriskClassCorrelations () const
 
void validate () const
 
const std::string & id () const
 

Detailed Description

Definition at line 37 of file simmcalibration.hpp.

Member Typedef Documentation

◆ Amounts

typedef std::map<std::tuple<std::string, std::string, std::string>, std::string> Amounts

Definition at line 39 of file simmcalibration.hpp.

◆ CurrencyLists

typedef std::map<std::tuple<std::string, std::string, std::string>, std::set<std::string> > CurrencyLists

Definition at line 40 of file simmcalibration.hpp.

Constructor & Destructor Documentation

◆ SimmCalibration() [1/2]

Definition at line 267 of file simmcalibration.hpp.

267{}

◆ SimmCalibration() [2/2]

Definition at line 268 of file simmcalibration.hpp.

268{ fromXML(node); }
void fromXML(ore::data::XMLNode *node) override
+ Here is the call graph for this function:

Member Function Documentation

◆ version()

const string & version ( ) const

Definition at line 521 of file simmcalibration.cpp.

521{ return versionNames_.front(); }
std::vector< std::string > versionNames_
+ Here is the caller graph for this function:

◆ versionNames()

const std::vector< std::string > & versionNames ( ) const

Definition at line 271 of file simmcalibration.hpp.

271{ return versionNames_; }
+ Here is the caller graph for this function:

◆ additionalFields()

const std::vector< std::pair< std::string, std::string > > & additionalFields ( ) const

Definition at line 272 of file simmcalibration.hpp.

272{ return additionalFields_; }
std::vector< std::pair< std::string, std::string > > additionalFields_
+ Here is the caller graph for this function:

◆ toXML()

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

Implements XMLSerializable.

Definition at line 523 of file simmcalibration.cpp.

523 {
524 XMLNode* simmCalibrationNode = doc.allocNode("SIMMCalibration");
525 XMLUtils::addAttribute(doc, simmCalibrationNode, "id", id_);
526
527 // Version names
528 XMLNode* versionNamesNode = doc.allocNode("VersionNames");
529 for (const string& vname : versionNames()) {
530 XMLUtils::addChild(doc, versionNamesNode, "Name", vname);
531 }
532 XMLUtils::appendNode(simmCalibrationNode, versionNamesNode);
533
534 // Additional fields
535 XMLNode* additionalFieldsNode = doc.allocNode("AdditionalFields");
536 for (const auto& [nodeName, nodeValue] : additionalFields()) {
537 XMLUtils::addChild(doc, additionalFieldsNode, nodeName, nodeValue);
538 }
539 XMLUtils::appendNode(simmCalibrationNode, additionalFieldsNode);
540
541 // Risk class-specific nodes (e.g. InterestRate, CreditQ, CreditNonQ, etc.)
542 for (const auto& [riskClass, rcData] : riskClassData_) {
543 const string rcString = ore::data::to_string(riskClass);
544 auto rcNode = rcData->toXML(doc);
545 XMLUtils::appendNode(simmCalibrationNode, rcNode);
546 }
547
548 // Risk class correlations
549 XMLNode* riskClassCorrelationsNode = doc.allocNode("RiskClassCorrelations");
550 for (const auto& [rcCorrKey, rcCorrelation] : riskClassCorrelations_) {
551 Amount amount(rcCorrKey, rcCorrelation);
552 auto corrNode = amount.toXML(doc);
553 XMLUtils::setNodeName(doc, corrNode, "Correlation");
554 XMLUtils::appendNode(riskClassCorrelationsNode, corrNode);
555 }
556 XMLUtils::appendNode(simmCalibrationNode, riskClassCorrelationsNode);
557 return simmCalibrationNode;
558}
const std::vector< std::pair< std::string, std::string > > & additionalFields() const
const std::vector< std::string > & versionNames() const
std::map< SimmConfiguration::RiskClass, QuantLib::ext::shared_ptr< RiskClassData > > riskClassData_
XMLNode * allocNode(const string &nodeName)
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
std::string to_string(const LocationInfo &l)
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( ore::data::XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 560 of file simmcalibration.cpp.

560 {
561 XMLUtils::checkNode(node, "SIMMCalibration");
562
563 id_ = XMLUtils::getAttribute(node, "id");
564
565 // Version names
566 XMLNode* versionNamesNode = XMLUtils::getChildNode(node, "VersionNames");
567 for (XMLNode* name : XMLUtils::getChildrenNodes(versionNamesNode, "Name"))
568 versionNames_.push_back(XMLUtils::getNodeValue(name));
569 QL_REQUIRE(!versionNames_.empty(), "Must provide at least one version name for SIMM calibration");
570
571 // Additional fields
572 XMLNode* addFieldsNode = XMLUtils::getChildNode(node, "AdditionalFields");
573 if (addFieldsNode)
574 for (XMLNode* child = XMLUtils::getChildNode(addFieldsNode); child; child = XMLUtils::getNextSibling(child))
575 additionalFields_.push_back(std::make_pair(XMLUtils::getNodeName(child), XMLUtils::getNodeValue(child)));
576
577 // Risk class-specific nodes (e.g. InterestRate, CreditQ, CreditNonQ, etc.)
578 XMLNode* riskClassNode;
579 for (const SimmConfiguration::RiskClass& rc :
580 { RC::InterestRate, RC::CreditQualifying, RC::CreditNonQualifying, RC::Equity, RC::Commodity, RC::FX }) {
581 riskClassNode = XMLUtils::getChildNode(node, ore::data::to_string(rc));
582 auto riskClassData = QuantLib::ext::make_shared<RiskClassData>(rc);
583 riskClassData->fromXML(riskClassNode);
585 }
586
587 // Risk class correlations
588 auto rcCorrsNode = XMLUtils::getChildNode(node, "RiskClassCorrelations");
590 for (auto rcCorrNode : XMLUtils::getChildrenNodes(rcCorrsNode, "Correlation")) {
591 Amount amount(rcCorrNode);
592 riskClassCorrelations_[amount.key()] = amount.value();
593 }
594}
const std::map< SimmConfiguration::RiskClass, QuantLib::ext::shared_ptr< RiskClassData > > & riskClassData() const
static string getAttribute(XMLNode *node, const string &attrName)
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
static string getNodeName(XMLNode *n)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ riskClassData()

const std::map< SimmConfiguration::RiskClass, QuantLib::ext::shared_ptr< RiskClassData > > & riskClassData ( ) const

Definition at line 279 of file simmcalibration.hpp.

279 {
280 return riskClassData_;
281 }
+ Here is the caller graph for this function:

◆ riskClassCorrelations()

const Amounts & riskClassCorrelations ( ) const

Definition at line 282 of file simmcalibration.hpp.

282{ return riskClassCorrelations_; }

◆ validate()

void validate ( ) const

Definition at line 285 of file simmcalibration.hpp.

285{}

◆ id()

const std::string & id ( ) const

Definition at line 287 of file simmcalibration.hpp.

287{ return id_; }

Member Data Documentation

◆ id_

std::string id_
private

Definition at line 290 of file simmcalibration.hpp.

◆ versionNames_

std::vector<std::string> versionNames_
private

Definition at line 291 of file simmcalibration.hpp.

◆ additionalFields_

std::vector<std::pair<std::string, std::string> > additionalFields_
private

Definition at line 292 of file simmcalibration.hpp.

◆ riskClassData_

std::map<SimmConfiguration::RiskClass, QuantLib::ext::shared_ptr<RiskClassData> > riskClassData_
private

Definition at line 293 of file simmcalibration.hpp.

◆ riskClassCorrelations_

Amounts riskClassCorrelations_
private

Definition at line 294 of file simmcalibration.hpp.