Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
basketdata.hpp
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
19/*! \file ored/portfolio/basketdata.hpp
20 \brief credit basket data model and serialization
21 \ingroup portfolio
22*/
23
24#pragma once
25
29#include <vector>
30
31namespace ore {
32namespace data {
33
34/*! Serializable credit basket data constituent
35 \ingroup tradedata
36*/
38public:
39
40 //! Default constructor
42
43 //! Constructor taking an explicit \p creditCurveId.
44 BasketConstituent(const std::string& issuerName, const std::string& creditCurveId, QuantLib::Real notional,
45 const std::string& currency, const std::string& qualifier,
46 QuantLib::Real priorNotional = QuantLib::Null<QuantLib::Real>(),
47 QuantLib::Real recovery = QuantLib::Null<QuantLib::Real>(),
48 const QuantLib::Date& auctionDate = QuantLib::Date(),
49 const QuantLib::Date& auctionSettlementDate = QuantLib::Date(),
50 const QuantLib::Date& defaultDate = QuantLib::Date(),
51 const QuantLib::Date& eventDeterminationDate = QuantLib::Date());
52
53 //! Constructor taking an explicit \p creditCurveId and initialized by weight.
54 BasketConstituent(const std::string& issuerName, const std::string& creditCurveId, QuantLib::Real weight,
55 const std::string& qualifier,
56 QuantLib::Real priorWeight = QuantLib::Null<QuantLib::Real>(),
57 QuantLib::Real recovery = QuantLib::Null<QuantLib::Real>(),
58 const QuantLib::Date& auctionDate = QuantLib::Date(),
59 const QuantLib::Date& auctionSettlementDate = QuantLib::Date(),
60 const QuantLib::Date& defaultDate = QuantLib::Date(),
61 const QuantLib::Date& eventDeterminationDate = QuantLib::Date());
62
63 //! Constructor taking CDS reference information, \p cdsReferenceInfo.
65 QuantLib::Real notional, const std::string& currency, const std::string& qualifier,
66 QuantLib::Real priorNotional = QuantLib::Null<QuantLib::Real>(),
67 QuantLib::Real recovery = QuantLib::Null<QuantLib::Real>(),
68 const QuantLib::Date& auctionDate = QuantLib::Date(),
69 const QuantLib::Date& auctionSettlementDate = QuantLib::Date(),
70 const QuantLib::Date& defaultDate = QuantLib::Date(),
71 const QuantLib::Date& eventDeterminationDate = QuantLib::Date());
72
73 //! \name Serialisation
74 //@{
75 void fromXML(ore::data::XMLNode* node) override;
77 //@}
78
79 //! \name Inspectors
80 //@{
81 const std::string& issuerName() const;
82 const std::string& creditCurveId() const;
83 const boost::optional<ore::data::CdsReferenceInformation>& cdsReferenceInfo() const;
84 QuantLib::Real notional() const;
85 const std::string& currency() const;
86 QuantLib::Real priorNotional() const;
87 QuantLib::Real recovery() const;
88 QuantLib::Real weight() const;
89 QuantLib::Real priorWeight() const;
90 const QuantLib::Date& auctionDate() const;
91 const QuantLib::Date& auctionSettlementDate() const;
92 const QuantLib::Date& defaultDate() const;
93 const QuantLib::Date& eventDeterminationDate() const;
94 bool weightInsteadOfNotional() const;
95 //@}
96
97private:
98
99 std::string issuerName_;
100 boost::optional<ore::data::CdsReferenceInformation> cdsReferenceInfo_;
101 std::string creditCurveId_;
102 QuantLib::Real notional_;
103 std::string currency_;
104 std::string qualifier_;
105 QuantLib::Real priorNotional_;
106 QuantLib::Real weight_;
107 QuantLib::Real priorWeight_;
108 QuantLib::Real recovery_;
109 QuantLib::Date auctionDate_;
111 QuantLib::Date defaultDate_;
114
115
116};
117
118/*! Compare BasketConstituent instances using their credit curve ID.
119
120 If credit curve ID is not enough here, we should construct a private key member variable in BasketConstituent and
121 make this operator a friend that uses the key.
122*/
123bool operator<(const BasketConstituent& lhs, const BasketConstituent& rhs);
124
125/*! Serializable credit basket data
126 \ingroup tradedata
127*/
129public:
130 //! Default constructor
131 BasketData();
132
133 //! Constructor taking explicit set of \p basket constituents.
134 BasketData(const std::vector<BasketConstituent>& constituents);
135
136 //! \name Inspectors
137 //@{
138 const std::vector<BasketConstituent>& constituents() const;
139 //@}
140
141 //! \name Serialisation
142 //@{
143 void fromXML(ore::data::XMLNode* node) override;
144 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
145 //@}
146
147private:
148 std::vector<BasketConstituent> constituents_;
149};
150
151}
152}
const std::string & currency() const
Definition: basketdata.cpp:216
QuantLib::Date eventDeterminationDate_
Definition: basketdata.hpp:112
QuantLib::Real weight() const
Definition: basketdata.cpp:231
bool weightInsteadOfNotional() const
Definition: basketdata.cpp:253
const QuantLib::Date & defaultDate() const
Definition: basketdata.cpp:249
boost::optional< ore::data::CdsReferenceInformation > cdsReferenceInfo_
Definition: basketdata.hpp:100
BasketConstituent()
Default constructor.
Definition: basketdata.cpp:36
void fromXML(ore::data::XMLNode *node) override
Definition: basketdata.cpp:69
QuantLib::Real notional() const
Definition: basketdata.cpp:210
QuantLib::Real priorNotional() const
Definition: basketdata.cpp:222
const QuantLib::Date & eventDeterminationDate() const
Definition: basketdata.cpp:251
BasketConstituent(const std::string &issuerName, const std::string &creditCurveId, QuantLib::Real weight, const std::string &qualifier, QuantLib::Real priorWeight=QuantLib::Null< QuantLib::Real >(), QuantLib::Real recovery=QuantLib::Null< QuantLib::Real >(), const QuantLib::Date &auctionDate=QuantLib::Date(), const QuantLib::Date &auctionSettlementDate=QuantLib::Date(), const QuantLib::Date &defaultDate=QuantLib::Date(), const QuantLib::Date &eventDeterminationDate=QuantLib::Date())
Constructor taking an explicit creditCurveId and initialized by weight.
QuantLib::Real recovery() const
Definition: basketdata.cpp:229
const QuantLib::Date & auctionDate() const
Definition: basketdata.cpp:245
QuantLib::Real priorWeight() const
Definition: basketdata.cpp:238
const boost::optional< ore::data::CdsReferenceInformation > & cdsReferenceInfo() const
Definition: basketdata.cpp:206
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
Definition: basketdata.cpp:137
BasketConstituent(const std::string &issuerName, const ore::data::CdsReferenceInformation &cdsReferenceInfo, QuantLib::Real notional, const std::string &currency, const std::string &qualifier, QuantLib::Real priorNotional=QuantLib::Null< QuantLib::Real >(), QuantLib::Real recovery=QuantLib::Null< QuantLib::Real >(), const QuantLib::Date &auctionDate=QuantLib::Date(), const QuantLib::Date &auctionSettlementDate=QuantLib::Date(), const QuantLib::Date &defaultDate=QuantLib::Date(), const QuantLib::Date &eventDeterminationDate=QuantLib::Date())
Constructor taking CDS reference information, cdsReferenceInfo.
const std::string & issuerName() const
Definition: basketdata.cpp:202
const QuantLib::Date & auctionSettlementDate() const
Definition: basketdata.cpp:247
QuantLib::Date auctionSettlementDate_
Definition: basketdata.hpp:110
const std::string & creditCurveId() const
Definition: basketdata.cpp:204
BasketConstituent(const std::string &issuerName, const std::string &creditCurveId, QuantLib::Real notional, const std::string &currency, const std::string &qualifier, QuantLib::Real priorNotional=QuantLib::Null< QuantLib::Real >(), QuantLib::Real recovery=QuantLib::Null< QuantLib::Real >(), const QuantLib::Date &auctionDate=QuantLib::Date(), const QuantLib::Date &auctionSettlementDate=QuantLib::Date(), const QuantLib::Date &defaultDate=QuantLib::Date(), const QuantLib::Date &eventDeterminationDate=QuantLib::Date())
Constructor taking an explicit creditCurveId.
void fromXML(ore::data::XMLNode *node) override
Definition: basketdata.cpp:265
const std::vector< BasketConstituent > & constituents() const
Definition: basketdata.cpp:263
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
Definition: basketdata.cpp:277
BasketData()
Default constructor.
Definition: basketdata.cpp:259
std::vector< BasketConstituent > constituents_
Definition: basketdata.hpp:148
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
A class to hold credit default swap data.
Pricing Engine Factory.
@ data
Definition: log.hpp:77
bool operator<(const Dividend &d1, const Dividend &d2)
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.