Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
durationadjustedcmslegdata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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
20
22
23namespace ore {
24namespace data {
25
27 XMLNode* node = doc.allocNode(legNodeName());
28 XMLUtils::addChild(doc, node, "Index", swapIndex_);
29 XMLUtils::addChild(doc, node, "Duration", static_cast<int>(duration_));
30 XMLUtils::addChild(doc, node, "IsInArrears", isInArrears_);
31 if (fixingDays_ != Null<Size>())
32 XMLUtils::addChild(doc, node, "FixingDays", static_cast<int>(fixingDays_));
33 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Caps", "Cap", caps_, "startDate", capDates_);
34 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Floors", "Floor", floors_, "startDate", floorDates_);
35 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Gearings", "Gearing", gearings_, "startDate",
37 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Spreads", "Spread", spreads_, "startDate", spreadDates_);
38 XMLUtils::addChild(doc, node, "NakedOption", nakedOption_);
39 return node;
40}
41
44 swapIndex_ = XMLUtils::getChildValue(node, "Index", true);
45 duration_ = XMLUtils::getChildValueAsInt(node, "Duration", false);
46 indices_.insert(swapIndex_);
47 // These are all optional
48 spreads_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Spreads", "Spread", "startDate", spreadDates_,
49 &parseReal);
50 XMLNode* arrNode = XMLUtils::getChildNode(node, "IsInArrears");
51 if (arrNode)
52 isInArrears_ = XMLUtils::getChildValueAsBool(node, "IsInArrears", true);
53 else
54 isInArrears_ = false; // default to fixing-in-advance
55 if (auto n = XMLUtils::getChildNode(node, "FixingDays"))
57 else
58 fixingDays_ = Null<Size>();
59 caps_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Caps", "Cap", "startDate", capDates_, &parseReal);
60 floors_ =
61 XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Floors", "Floor", "startDate", floorDates_, &parseReal);
62 gearings_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Gearings", "Gearing", "startDate", gearingDates_,
63 &parseReal);
64 if (XMLUtils::getChildNode(node, "NakedOption"))
65 nakedOption_ = XMLUtils::getChildValueAsBool(node, "NakedOption", false);
66 else
67 nakedOption_ = false;
68}
69
70} // namespace data
71} // namespace ore
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
std::set< std::string > indices_
Definition: legdata.hpp:77
const string & legNodeName() const
Definition: legdata.hpp:70
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 checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
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 void addChildrenWithOptionalAttributes(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values, const string &attrName, const vector< string > &attrs)
Definition: xmlutils.cpp:542
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
leg data for duration adjusted cms
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
leg data model and serialization
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23