QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
cdo.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Roland Lichters
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_cdo_hpp
25#define quantlib_cdo_hpp
26
27#include <ql/instrument.hpp>
28#include <ql/termstructures/yieldtermstructure.hpp>
29#include <ql/termstructures/defaulttermstructure.hpp>
30#include <ql/experimental/credit/lossdistribution.hpp>
31#include <ql/experimental/credit/onefactorcopula.hpp>
32#include <ql/time/schedule.hpp>
33
34namespace QuantLib {
35
37
98 class CDO : public Instrument {
99 public:
123 std::vector<Real> nominals,
124 const std::vector<Handle<DefaultProbabilityTermStructure> >& basket,
126 bool protectionSeller,
127 Schedule premiumSchedule,
128 Rate premiumRate,
129 DayCounter dayCounter,
130 Rate recoveryRate,
131 Rate upfrontPremiumRate,
133 Size nBuckets,
134 const Period& integrationStep = Period(10, Years));
135
136 Real nominal() const { return nominal_; }
137 Real lgd() const { return lgd_; }
138 Real attachment() const { return attachment_; }
139 Real detachment() const { return detachment_; }
140 std::vector<Real> nominals() { return nominals_; }
141 Size size() { return basket_.size(); }
142
143 bool isExpired() const override;
144 Rate fairPremium() const;
145 Rate premiumValue () const;
146 Rate protectionValue () const;
147 Size error () const;
148
149 private:
150 void setupExpired() const override;
151 void performCalculations() const override;
152 Real expectedTrancheLoss (Date d) const;
153
156 std::vector<Real> nominals_;
157 std::vector<Handle<DefaultProbabilityTermStructure> > basket_;
160
167 Size nBuckets_; // number of buckets up to detachment point
169
170 std::vector<Real> lgds_;
171
172 Real nominal_; // total basket volume (sum of nominals_)
173 Real lgd_; // maximum loss given default (sum of lgds_)
174 Real xMax_; // tranche detachment point (tranche_ * nominal_)
175 Real xMin_; // tranche attachment point (tranche_ * nominal_)
176
177 mutable Size error_;
178
182 };
183
184}
185
186#endif
collateralized debt obligation
Definition: cdo.hpp:98
Real upfrontPremiumValue_
Definition: cdo.hpp:181
Real nominal_
Definition: cdo.hpp:172
Real protectionValue_
Definition: cdo.hpp:180
Size error() const
Definition: cdo.cpp:198
void performCalculations() const override
Definition: cdo.cpp:118
Real premiumValue_
Definition: cdo.hpp:179
Real lgd() const
Definition: cdo.hpp:137
bool isExpired() const override
returns whether the instrument might have value greater than zero.
Definition: cdo.cpp:84
Real lgd_
Definition: cdo.hpp:173
std::vector< Real > nominals()
Definition: cdo.hpp:140
Real attachment() const
Definition: cdo.hpp:138
Real xMin_
Definition: cdo.hpp:175
Rate upfrontPremiumRate_
Definition: cdo.hpp:165
Real attachment_
Definition: cdo.hpp:154
bool protectionSeller_
Definition: cdo.hpp:159
DayCounter dayCounter_
Definition: cdo.hpp:163
Handle< OneFactorCopula > copula_
Definition: cdo.hpp:158
Rate protectionValue() const
Definition: cdo.cpp:193
Real nominal() const
Definition: cdo.hpp:136
Rate premiumRate_
Definition: cdo.hpp:162
Size size()
Definition: cdo.hpp:141
Rate recoveryRate_
Definition: cdo.hpp:164
Real xMax_
Definition: cdo.hpp:174
Real expectedTrancheLoss(Date d) const
Definition: cdo.cpp:95
Rate fairPremium() const
Definition: cdo.cpp:203
void setupExpired() const override
Definition: cdo.cpp:90
Schedule premiumSchedule_
Definition: cdo.hpp:161
std::vector< Real > lgds_
Definition: cdo.hpp:170
Real detachment_
Definition: cdo.hpp:155
Rate premiumValue() const
Definition: cdo.cpp:188
Size nBuckets_
Definition: cdo.hpp:167
Size error_
Definition: cdo.hpp:177
Period integrationStep_
Definition: cdo.hpp:168
std::vector< Real > nominals_
Definition: cdo.hpp:156
std::vector< Handle< DefaultProbabilityTermStructure > > basket_
Definition: cdo.hpp:157
Handle< YieldTermStructure > yieldTS_
Definition: cdo.hpp:166
Real detachment() const
Definition: cdo.hpp:139
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
Abstract instrument class.
Definition: instrument.hpp:44
Payment schedule.
Definition: schedule.hpp:40
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35