Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cdo.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 portfolio/capfloor.hpp
20 \brief Ibor cap, floor or collar trade data model and serialization
21 \ingroup portfolio
22*/
23
24#pragma once
25
28
31
32namespace ore {
33namespace data {
34
35//! Serializable CDS Index Tranche (Synthetic CDO)
36/*! \ingroup tradedata
37 */
38
39
40class SyntheticCDO : public Trade {
41public:
42 SyntheticCDO() : Trade("SyntheticCDO"),
43 attachmentPoint_(Null<Real>()), detachmentPoint_(Null<Real>()), settlesAccrual_(true),
44 protectionPaymentTime_(QuantExt::CreditDefaultSwap::ProtectionPaymentTime::atDefault),
45 upfrontFee_(Null<Real>()), rebatesAccrual_(true), recoveryRate_(Null<Real>()),
48 const Envelope& env, const LegData& leg, const string& qualifier, const BasketData& basketData,
49 double attachmentPoint, double detachmentPoint, const bool settlesAccrual = true,
50 const QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime =
51 QuantExt::CreditDefaultSwap::ProtectionPaymentTime::atDefault,
52 const string& protectionStart = string(), const string& upfrontDate = string(),
53 const Real upfrontFee = Null<Real>(), const bool rebatesAccrual = true, Real recoveryRate = Null<Real>())
54 : Trade("SyntheticCDO", env), qualifier_(qualifier), legData_(leg), basketData_(basketData),
55 attachmentPoint_(attachmentPoint), detachmentPoint_(detachmentPoint), settlesAccrual_(settlesAccrual),
59
60 virtual void build(const QuantLib::ext::shared_ptr<EngineFactory>&) override;
61
62 //! Inspectors
63 //@{
64 const string& qualifier() const { return qualifier_; }
65 const LegData& leg() const { return legData_; }
66 const BasketData& basketData() const { return basketData_; }
67 const double& attachmentPoint() const { return attachmentPoint_; }
68 const double& detachmentPoint() const { return detachmentPoint_; }
69 QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime() const { return protectionPaymentTime_; }
70 const string& protectionStart() const { return protectionStart_; }
71 const string& upfrontDate() const { return upfrontDate_; }
72 const double& upfrontFee() const { return upfrontFee_; }
73 bool settlesAccrual() const { return settlesAccrual_; }
74 bool rebatesAccrual() const { return rebatesAccrual_; }
75 const Real& recoveryRate() const { return recoveryRate_; }
77 const std::map<std::string, Real>& basketConstituents() const { return basketConstituents_; }
78 //@}
79
80 virtual void fromXML(XMLNode* node) override;
81 virtual XMLNode* toXML(XMLDocument& doc) const override;
82
83 static vector<Time>
84 extractTimeGridDefaultCurve(const QuantLib::Handle<QuantLib::DefaultProbabilityTermStructure>& dpts);
85 QuantLib::Handle<QuantLib::DefaultProbabilityTermStructure> static buildCalibratedConstiuentCurve(
86 const QuantLib::Handle<QuantLib::DefaultProbabilityTermStructure>& curve,
87 const QuantLib::ext::shared_ptr<SimpleQuote>& calibrationFactor);
88
89 /*! Get credit curve id with term suffix "_5Y". If the creditCurveId contains such a suffix already
90 this is used. Otherwise we try to imply it from the schedule. If that is not possible, the
91 creditCurveId without tenor is returned. */
92 std::string creditCurveIdWithTerm() const;
93
94 /*! If set this is used to derive the term instead of the schedule start date. A concession to bad
95 trade setups really, where the start date is not set to the index effective date */
96 void setIndexStartDateHint(const QuantLib::Date& d) const { indexStartDateHint_ = d; }
97
98 /*! Get the index start date hint, or null if it was never set */
99 const QuantLib::Date& indexStartDateHint() const { return indexStartDateHint_; }
100
101private:
102
103 bool isIndexTranche() const { return qualifier_.size() == 13 && qualifier_.substr(0, 3) == "RED"; }
104
111 QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime_;
117
118 // Need these stored in case we use the simplification and need to recontribute the total sensitivities
119 // to the underlyings in the basket.
120 std::map<std::string, double> basketConstituents_;
122 mutable QuantLib::Date indexStartDateHint_;
123};
124} // namespace data
125} // namespace ore
credit basket data model and serialization
QuantLib::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime_
Real recoveryRate() const
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable object holding leg data.
Definition: legdata.hpp:844
bool useSensitivitySimplification() const
Definition: cdo.hpp:76
bool isIndexTranche() const
Definition: cdo.hpp:103
QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime_
Definition: cdo.hpp:111
const double & attachmentPoint() const
Definition: cdo.hpp:67
const string & upfrontDate() const
Definition: cdo.hpp:71
const string & protectionStart() const
Definition: cdo.hpp:70
bool useSensitivitySimplification_
Definition: cdo.hpp:121
void setIndexStartDateHint(const QuantLib::Date &d) const
Definition: cdo.hpp:96
QuantLib::Date indexStartDateHint_
Definition: cdo.hpp:122
const double & detachmentPoint() const
Definition: cdo.hpp:68
const LegData & leg() const
Definition: cdo.hpp:65
const string & qualifier() const
Inspectors.
Definition: cdo.hpp:64
string protectionStart_
Definition: cdo.hpp:112
const Real & recoveryRate() const
Definition: cdo.hpp:75
SyntheticCDO(const Envelope &env, const LegData &leg, const string &qualifier, const BasketData &basketData, double attachmentPoint, double detachmentPoint, const bool settlesAccrual=true, const QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime=QuantExt::CreditDefaultSwap::ProtectionPaymentTime::atDefault, const string &protectionStart=string(), const string &upfrontDate=string(), const Real upfrontFee=Null< Real >(), const bool rebatesAccrual=true, Real recoveryRate=Null< Real >())
Definition: cdo.hpp:47
const std::map< std::string, Real > & basketConstituents() const
Definition: cdo.hpp:77
bool settlesAccrual() const
Definition: cdo.hpp:73
const BasketData & basketData() const
Definition: cdo.hpp:66
double detachmentPoint_
Definition: cdo.hpp:109
QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime() const
Definition: cdo.hpp:69
const QuantLib::Date & indexStartDateHint() const
Definition: cdo.hpp:99
const double & upfrontFee() const
Definition: cdo.hpp:72
std::map< std::string, double > basketConstituents_
Definition: cdo.hpp:120
BasketData basketData_
Definition: cdo.hpp:107
double attachmentPoint_
Definition: cdo.hpp:108
bool rebatesAccrual() const
Definition: cdo.hpp:74
Trade base class.
Definition: trade.hpp:55
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
leg data model and serialization
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Reference data model and serialization.
base trade data model and serialization