Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
indexing.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
20
22
23namespace ore {
24namespace data {
25
27 XMLUtils::checkNode(node, "Indexing");
28 if (auto n = XMLUtils::getChildNode(node, "Quantity")) {
30 } else {
31 quantity_ = 1.0;
32 }
33 index_ = XMLUtils::getChildValue(node, "Index", false);
34 indexFixingCalendar_ = XMLUtils::getChildValue(node, "IndexFixingCalendar", false);
35 if (XMLUtils::getChildNode(node, "IndexFixingDays")) {
36 WLOG("Indexing::fromXML, node IndexFixingDays has been deprecated, fixing days are "
37 "taken from conventions.");
38 }
39 indexIsDirty_ = XMLUtils::getChildValueAsBool(node, "Dirty", false);
40 indexIsRelative_ = XMLUtils::getChildValueAsBool(node, "Relative", false);
41 indexIsConditionalOnSurvival_ = XMLUtils::getChildValueAsBool(node, "ConditionalOnSurvival", false);
42 initialFixing_ = Null<Real>();
43 if (auto n = XMLUtils::getChildNode(node, "InitialFixing"))
45 initialNotionalFixing_ = Null<Real>();
46 if (auto n = XMLUtils::getChildNode(node, "InitialNotionalFixing"))
48 if (auto tmp = XMLUtils::getChildNode(node, "ValuationSchedule"))
50 fixingDays_ = 0;
51 if (auto n = XMLUtils::getChildNode(node, "FixingDays"))
53 fixingCalendar_ = XMLUtils::getChildValue(node, "FixingCalendar");
54 fixingConvention_ = XMLUtils::getChildValue(node, "FixingConvention");
55 inArrearsFixing_ = false;
56 if (auto n = XMLUtils::getChildNode(node, "IsInArrears"))
58 hasData_ = true;
59}
60
62 XMLNode* node = doc.allocNode("Indexing");
63 XMLUtils::addChild(doc, node, "Quantity", quantity_);
64 XMLUtils::addChild(doc, node, "Index", index_);
65 XMLUtils::addChild(doc, node, "IndexFixingCalendar", indexFixingCalendar_);
66 XMLUtils::addChild(doc, node, "Dirty", indexIsDirty_);
67 XMLUtils::addChild(doc, node, "Relative", indexIsRelative_);
68 XMLUtils::addChild(doc, node, "ConditionalOnSurvival", indexIsConditionalOnSurvival_);
69 if (initialFixing_ != Null<Real>())
70 XMLUtils::addChild(doc, node, "InitialFixing", initialFixing_);
71 if (initialNotionalFixing_ != Null<Real>())
72 XMLUtils::addChild(doc, node, "InitialNotionalFixing", initialNotionalFixing_);
74 XMLNode* schedNode = valuationSchedule_.toXML(doc);
75 XMLUtils::setNodeName(doc, schedNode, "ValuationSchedule");
76 XMLUtils::appendNode(node, schedNode);
77 }
78 XMLUtils::addChild(doc, node, "FixingDays", static_cast<int>(fixingDays_));
79 XMLUtils::addChild(doc, node, "FixingCalendar", fixingCalendar_);
80 XMLUtils::addChild(doc, node, "FixingConvention", fixingConvention_);
81 XMLUtils::addChild(doc, node, "IsInArrears", inArrearsFixing_);
82 return node;
83}
84
85} // namespace data
86} // namespace ore
ScheduleData valuationSchedule_
Definition: indexing.hpp:112
string fixingConvention_
Definition: indexing.hpp:115
virtual void fromXML(XMLNode *node) override
Definition: indexing.cpp:26
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: indexing.cpp:61
string indexFixingCalendar_
Definition: indexing.hpp:106
bool indexIsConditionalOnSurvival_
Definition: indexing.hpp:109
bool hasData() const
Check if has any dates/rules/derived schedules.
Definition: schedule.hpp:223
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
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 string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
Definition: xmlutils.cpp:478
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
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 indexing data model and serialization
@ data
Definition: log.hpp:77
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.