Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
eqbsdata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
22
23namespace ore {
24namespace data {
25
27
28 if (name_ != rhs.name_ || ccy_ != rhs.ccy_ || calibrationType_ != rhs.calibrationType_ ||
32 return false;
33 }
34 return true;
35}
36
37bool EqBsData::operator!=(const EqBsData& rhs) { return !(*this == rhs); }
38
40 name_ = XMLUtils::getAttribute(node, "name");
41 LOG("Cross-Asset Equity Name = " << name_);
42
43 ccy_ = XMLUtils::getChildValue(node, "Currency", true);
44 LOG("Cross-Asset Equity Currency = " << ccy_);
45
46 std::string calibTypeString = XMLUtils::getChildValue(node, "CalibrationType", true);
47 calibrationType_ = parseCalibrationType(calibTypeString);
48 LOG("Cross-Asset Equity calibration type = " << calibTypeString);
49
50 XMLNode* sigmaNode = XMLUtils::getChildNode(node, "Sigma");
51 calibrateSigma_ = XMLUtils::getChildValueAsBool(sigmaNode, "Calibrate", true);
52 LOG("Cross-Asset Equity Sigma calibrate = " << calibrateSigma_);
53
54 std::string sigmaTypeString = XMLUtils::getChildValue(sigmaNode, "ParamType", true);
55 sigmaType_ = parseParamType(sigmaTypeString);
56 LOG("Cross-Asset Equity Sigma parameter type = " << sigmaTypeString);
57
58 sigmaTimes_ = XMLUtils::getChildrenValuesAsDoublesCompact(sigmaNode, "TimeGrid", true);
59 LOG("Cross-Asset Equity Sigma time grid size = " << sigmaTimes_.size());
60
61 sigmaValues_ = XMLUtils::getChildrenValuesAsDoublesCompact(sigmaNode, "InitialValue", true);
62 LOG("Cross-Asset Equity Sigma initial values size = " << sigmaValues_.size());
63
64 // Add FX Option calibration instruments
65 XMLNode* optionsNode = XMLUtils::getChildNode(node, "CalibrationOptions");
66
67 optionExpiries_ = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Expiries", true);
68 optionStrikes_ = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Strikes", false);
69
70 if (optionStrikes_.size() > 0) {
71 QL_REQUIRE(optionExpiries_.size() == optionStrikes_.size(),
72 "size mismatch in equity option expiries/strike for equity name " << name_);
73 } else // default ATMF
74 optionStrikes_.resize(optionExpiries_.size(), "ATMF");
75}
76
78
79 XMLNode* crossCcyLGMNode = doc.allocNode("CrossAssetLGM");
80 XMLUtils::addAttribute(doc, crossCcyLGMNode, "name", name_);
81
82 XMLUtils::addChild(doc, crossCcyLGMNode, "Currency", ccy_);
83 XMLUtils::addGenericChild(doc, crossCcyLGMNode, "CalibrationType", calibrationType_);
84
85 XMLNode* sigmaNode = XMLUtils::addChild(doc, crossCcyLGMNode, "Sigma");
86 XMLUtils::addChild(doc, sigmaNode, "Calibrate", calibrateSigma_);
87 XMLUtils::addGenericChild(doc, sigmaNode, "ParamType", sigmaType_);
88 XMLUtils::addGenericChildAsList(doc, sigmaNode, "TimeGrid", sigmaTimes_);
89 XMLUtils::addGenericChildAsList(doc, sigmaNode, "InitialValue", sigmaValues_);
90
91 XMLNode* calibrationOptionsNode = XMLUtils::addChild(doc, crossCcyLGMNode, "CalibrationOptions");
92 XMLUtils::addGenericChildAsList(doc, calibrationOptionsNode, "Expiries", optionExpiries_);
93 XMLUtils::addGenericChildAsList(doc, calibrationOptionsNode, "Strikes", optionStrikes_);
94
95 return crossCcyLGMNode;
96}
97} // namespace data
98} // namespace ore
EQ Model Parameters.
Definition: eqbsdata.hpp:50
std::string ccy_
Definition: eqbsdata.hpp:91
void fromXML(XMLNode *node)
Definition: eqbsdata.cpp:39
CalibrationType calibrationType_
Definition: eqbsdata.hpp:92
ParamType sigmaType_
Definition: eqbsdata.hpp:94
std::string name_
Definition: eqbsdata.hpp:90
std::vector< std::string > optionExpiries_
Definition: eqbsdata.hpp:97
XMLNode * toXML(XMLDocument &doc)
Definition: eqbsdata.cpp:77
std::vector< Time > sigmaTimes_
Definition: eqbsdata.hpp:95
std::vector< Real > sigmaValues_
Definition: eqbsdata.hpp:96
bool operator==(const EqBsData &rhs)
Definition: eqbsdata.cpp:26
bool operator!=(const EqBsData &rhs)
Definition: eqbsdata.cpp:37
std::vector< std::string > optionStrikes_
Definition: eqbsdata.hpp:98
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
Definition: xmlutils.cpp:412
static string getAttribute(XMLNode *node, const string &attrName)
Definition: xmlutils.cpp:419
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 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
static vector< Real > getChildrenValuesAsDoublesCompact(XMLNode *node, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:327
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
EQ component data for the cross asset model.
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#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
ParamType parseParamType(const string &s)
Convert parameter type string into enumerated class value.
Definition: irmodeldata.cpp:38
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.