Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
crlgmdata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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 name_ = XMLUtils::getAttribute(node, "name");
28 LOG("LGM with attribute (name) = " << name_);
29
30 // Calibration Swaptions
31
32 XMLNode* optionsNode = XMLUtils::getChildNode(node, "CalibrationCdsOptions");
33
34 if (optionsNode) {
35
36 optionExpiries() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Expiries", false);
37 optionTerms() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Terms", false);
38 QL_REQUIRE(optionExpiries().size() == optionTerms().size(),
39 "vector size mismatch in cds option expiries/terms for name " << name_);
40 optionStrikes() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Strikes", false);
41 if (optionStrikes().size() > 0) {
42 QL_REQUIRE(optionStrikes().size() == optionExpiries().size(),
43 "vector size mismatch in cds option expiries/strikes for name " << name_);
44 } else // Default: ATM
45 optionStrikes().resize(optionExpiries().size(), "ATM");
46
47 for (Size i = 0; i < optionExpiries().size(); i++) {
48 LOG("LGM calibration cds option " << optionExpiries()[i] << " x " << optionTerms()[i] << " "
49 << optionStrikes()[i]);
50 }
51 }
52
53 LgmData::fromXML(node);
54}
55
57 XMLNode* node = LgmData::toXML(doc);
58 XMLUtils::addAttribute(doc, node, "name", name_);
59
60 // swaption calibration
61 XMLNode* calibrationSwaptionsNode = XMLUtils::addChild(doc, node, "CalibrationCdsOptions");
62 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Expiries", optionExpiries());
63 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Terms", optionTerms());
64 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Strikes", optionStrikes());
65
66 return node;
67}
68} // namespace data
69} // namespace ore
std::string name_
Definition: crlgmdata.hpp:80
void fromXML(XMLNode *node) override
Definition: crlgmdata.cpp:26
XMLNode * toXML(XMLDocument &doc) const override
Definition: crlgmdata.cpp:56
std::vector< std::string > & optionExpiries() const
Definition: lgmdata.hpp:121
virtual void fromXML(XMLNode *node) override
Definition: lgmdata.cpp:145
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: lgmdata.cpp:207
std::vector< std::string > & optionTerms() const
Definition: lgmdata.hpp:122
std::vector< std::string > & optionStrikes() const
Definition: lgmdata.hpp:123
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
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 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 XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
CR 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
Size size(const ValueType &v)
Definition: value.cpp:145
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.