Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
indexcreditdefaultswapdata.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
20
26
28
29using namespace QuantLib;
30using namespace QuantExt;
39using std::string;
40
41namespace ore {
42namespace data {
43
45
47 const BasketData& basket,
48 const LegData& leg,
49 const bool settlesAccrual,
50 const PPT protectionPaymentTime,
51 const Date& protectionStart,
52 const Date& upfrontDate,
53 const Real upfrontFee,
54 const Date& tradeDate,
55 const string& cashSettlementDays,
56 const bool rebatesAccrual)
57 : CreditDefaultSwapData("", creditCurveId, leg, settlesAccrual, protectionPaymentTime, protectionStart,
58 upfrontDate, upfrontFee, Null<Real>(), "", tradeDate, cashSettlementDays, rebatesAccrual),
59 basket_(basket) {}
60
62
64
65 if (auto basketNode = XMLUtils::getChildNode(node, "BasketData"))
66 basket_.fromXML(basketNode);
67
68 indexStartDateHint_ = parseDate(XMLUtils::getChildValue(node, "IndexStartDateHint", false));
69}
70
72
75 if(indexStartDateHint_ != Date()) {
76 XMLUtils::addChild(doc, node, "IndexStartDateHint", ore::data::to_string(indexStartDateHint_));
77 }
78
79 return node;
80}
81
83 XMLUtils::checkNode(node, "IndexCreditDefaultSwapData");
84}
85
87 return doc.allocNode("IndexCreditDefaultSwapData");
88}
89
92 if (p.second != 0 * Days)
93 return creditCurveId();
94 QuantLib::Schedule s = makeSchedule(leg().schedule());
95 if (s.dates().empty())
96 return p.first;
97 QuantLib::Period t = QuantExt::implyIndexTerm(
98 indexStartDateHint_ == Date() ? s.dates().front() : indexStartDateHint_, s.dates().back());
99 if (t != 0 * Days)
100 return p.first + "_" + ore::data::to_string(t);
101 return p.first;
102}
103
104} // namespace data
105} // namespace ore
void fromXML(ore::data::XMLNode *node) override
Definition: basketdata.cpp:265
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
Definition: basketdata.cpp:277
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
ore::data::XMLNode * alloc(ore::data::XMLDocument &doc) const override
void fromXML(ore::data::XMLNode *node) override
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
void check(ore::data::XMLNode *node) const override
Serializable object holding leg data.
Definition: legdata.hpp:844
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
XML Utilities Class.
Definition: xmlutils.hpp:119
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 XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
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
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
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
leg data model and serialization
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
market data related utilties
QuantLib::Period implyIndexTerm(const Date &startDate, const Date &endDate)
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
std::pair< std::string, QuantLib::Period > splitCurveIdWithTenor(const std::string &creditCurveId)
Definition: marketdata.cpp:231
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.
string conversion utilities