Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
irlgmdata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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
23
24namespace ore {
25namespace data {
26
29 if(qualifier_.empty()) {
30 std::string ccy = XMLUtils::getAttribute(node, "ccy");
31 if(!ccy.empty()) {
33 WLOG("IrLgmData: attribute ccy is deprecated, use key instead.");
34 }
35 }
36 LOG("LGM with attribute (key) = " << qualifier_);
37
38 // Calibration Swaptions
39
40 if (XMLNode* optionsNode = XMLUtils::getChildNode(node, "CalibrationSwaptions")) {
41 optionExpiries() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Expiries", false);
42 optionTerms() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Terms", false);
43 QL_REQUIRE(optionExpiries().size() == optionTerms().size(),
44 "vector size mismatch in swaption expiries/terms for ccy " << qualifier_);
45 optionStrikes() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Strikes", false);
46 if (optionStrikes().size() > 0) {
47 QL_REQUIRE(optionStrikes().size() == optionExpiries().size(),
48 "vector size mismatch in swaption expiries/strikes for ccy " << qualifier_);
49 } else // Default: ATM
50 optionStrikes().resize(optionExpiries().size(), "ATM");
51
52 for (Size i = 0; i < optionExpiries().size(); i++) {
53 LOG("LGM calibration swaption " << optionExpiries()[i] << " x " << optionTerms()[i] << " "
54 << optionStrikes()[i]);
55 }
56 }
57 LgmData::fromXML(node);
58}
59
61 XMLNode* node = LgmData::toXML(doc);
62 XMLUtils::addAttribute(doc, node, "key", qualifier_);
63
64 // swaption calibration
65 XMLNode* calibrationSwaptionsNode = XMLUtils::addChild(doc, node, "CalibrationSwaptions");
66 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Expiries", optionExpiries());
67 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Terms", optionTerms());
68 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Strikes", optionStrikes());
69
70 return node;
71}
72
73} // namespace data
74} // namespace ore
void fromXML(XMLNode *node) override
Definition: irlgmdata.cpp:27
XMLNode * toXML(XMLDocument &doc) const override
Definition: irlgmdata.cpp:60
virtual std::string ccy() const
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
Map text representations to QuantLib/QuantExt types.
IR 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
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
Size size(const ValueType &v)
Definition: value.cpp:145
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.