QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
collateralized debt obligation More...
#include <cdo.hpp>
Public Member Functions | |
CDO (Real attachment, Real detachment, std::vector< Real > nominals, const std::vector< Handle< DefaultProbabilityTermStructure > > &basket, Handle< OneFactorCopula > copula, bool protectionSeller, Schedule premiumSchedule, Rate premiumRate, DayCounter dayCounter, Rate recoveryRate, Rate upfrontPremiumRate, Handle< YieldTermStructure > yieldTS, Size nBuckets, const Period &integrationStep=Period(10, Years)) | |
Real | nominal () const |
Real | lgd () const |
Real | attachment () const |
Real | detachment () const |
std::vector< Real > | nominals () |
Size | size () |
bool | isExpired () const override |
returns whether the instrument might have value greater than zero. More... | |
Rate | fairPremium () const |
Rate | premiumValue () const |
Rate | protectionValue () const |
Size | error () const |
Public Member Functions inherited from Instrument | |
Instrument () | |
Real | NPV () const |
returns the net present value of the instrument. More... | |
Real | errorEstimate () const |
returns the error estimate on the NPV when available. More... | |
const Date & | valuationDate () const |
returns the date the net present value refers to. More... | |
template<typename T > | |
T | result (const std::string &tag) const |
returns any additional result returned by the pricing engine. More... | |
const std::map< std::string, ext::any > & | additionalResults () const |
returns all additional result returned by the pricing engine. More... | |
void | setPricingEngine (const ext::shared_ptr< PricingEngine > &) |
set the pricing engine to be used. More... | |
virtual void | setupArguments (PricingEngine::arguments *) const |
virtual void | fetchResults (const PricingEngine::results *) const |
Public Member Functions inherited from LazyObject | |
LazyObject () | |
~LazyObject () override=default | |
void | update () override |
bool | isCalculated () const |
void | forwardFirstNotificationOnly () |
void | alwaysForwardNotifications () |
void | recalculate () |
void | freeze () |
void | unfreeze () |
Public Member Functions inherited from Observable | |
Observable () | |
Observable (const Observable &) | |
Observable & | operator= (const Observable &) |
Observable (Observable &&)=delete | |
Observable & | operator= (Observable &&)=delete |
virtual | ~Observable ()=default |
void | notifyObservers () |
Public Member Functions inherited from Observer | |
Observer ()=default | |
Observer (const Observer &) | |
Observer & | operator= (const Observer &) |
virtual | ~Observer () |
std::pair< iterator, bool > | registerWith (const ext::shared_ptr< Observable > &) |
void | registerWithObservables (const ext::shared_ptr< Observer > &) |
Size | unregisterWith (const ext::shared_ptr< Observable > &) |
void | unregisterWithAll () |
virtual void | update ()=0 |
virtual void | deepUpdate () |
Private Member Functions | |
void | setupExpired () const override |
void | performCalculations () const override |
Real | expectedTrancheLoss (Date d) const |
Private Attributes | |
Real | attachment_ |
Real | detachment_ |
std::vector< Real > | nominals_ |
std::vector< Handle< DefaultProbabilityTermStructure > > | basket_ |
Handle< OneFactorCopula > | copula_ |
bool | protectionSeller_ |
Schedule | premiumSchedule_ |
Rate | premiumRate_ |
DayCounter | dayCounter_ |
Rate | recoveryRate_ |
Rate | upfrontPremiumRate_ |
Handle< YieldTermStructure > | yieldTS_ |
Size | nBuckets_ |
Period | integrationStep_ |
std::vector< Real > | lgds_ |
Real | nominal_ |
Real | lgd_ |
Real | xMax_ |
Real | xMin_ |
Size | error_ |
Real | premiumValue_ |
Real | protectionValue_ |
Real | upfrontPremiumValue_ |
Additional Inherited Members | |
Public Types inherited from Observer | |
typedef set_type::iterator | iterator |
Protected Member Functions inherited from Instrument | |
void | calculate () const override |
void | performCalculations () const override |
Protected Member Functions inherited from LazyObject | |
Protected Attributes inherited from Instrument | |
Real | NPV_ |
Real | errorEstimate_ |
Date | valuationDate_ |
std::map< std::string, ext::any > | additionalResults_ |
ext::shared_ptr< PricingEngine > | engine_ |
Protected Attributes inherited from LazyObject | |
bool | calculated_ = false |
bool | frozen_ = false |
bool | alwaysForward_ |
collateralized debt obligation
The instrument prices a mezzanine CDO tranche with loss given default between attachment point \( D_1\) and detachment point \( D_2 > D_1 \).
For purchased protection, the instrument value is given by the difference of the protection value \( V_1 \) and premium value \( V_2 \),
\[ V = V_1 - V_2. \]
The protection leg is priced as follows:
\[ Pay(L) = min (D_1, LGD) - min (D_2, LGD) = \left\{ \begin{array}{lcl} \displaystyle 0 &;& LGD < D_1 \\ \displaystyle LGD - D_1 &;& D_1 \leq LGD \leq D_2 \\ \displaystyle D_2 - D_1 &;& LGD > D_2 \end{array} \right. \]
\[ V_1 \:=\: \sum_{i=1}^N (E_i - E_{i-1}) \cdot d_i \]
where \( d_i\) is the discount factor at time/date \( t_i \)The premium is paid on the protected notional amount, initially \( D_2 - D_1. \) This notional amount is reduced by the expected protection payments \( E_i \) at times \( t_i, \) so that the premium value is calculated as
\[ V_2 = m \, \cdot \sum_{i=1}^N \,(D_2 - D_1 - E_i) \cdot \Delta_{i-1,i}\,d_i \]
where \( m \) is the premium rate, \( \Delta_{i-1, i}\) is the day count fraction between date/time \( t_{i-1}\) and \( t_i.\)
The construction of the portfolio loss distribution \( E_i \) is based on the probability bucketing algorithm described in
John Hull and Alan White, "Valuation of a CDO and nth to default CDS without Monte Carlo simulation", Journal of Derivatives 12, 2, 2004
The pricing algorithm allows for varying notional amounts and default termstructures of the underlyings.
CDO | ( | Real | attachment, |
Real | detachment, | ||
std::vector< Real > | nominals, | ||
const std::vector< Handle< DefaultProbabilityTermStructure > > & | basket, | ||
Handle< OneFactorCopula > | copula, | ||
bool | protectionSeller, | ||
Schedule | premiumSchedule, | ||
Rate | premiumRate, | ||
DayCounter | dayCounter, | ||
Rate | recoveryRate, | ||
Rate | upfrontPremiumRate, | ||
Handle< YieldTermStructure > | yieldTS, | ||
Size | nBuckets, | ||
const Period & | integrationStep = Period(10, Years) |
||
) |
attachment | fraction of the LGD where protection starts |
detachment | fraction of the LGD where protection ends |
nominals | vector of basket nominal amounts |
basket | default basket represented by a vector of default term structures that allow computing single name default probabilities depending on time |
copula | one-factor copula |
protectionSeller | sold protection if set to true, purchased otherwise |
premiumSchedule | schedule for premium payments |
premiumRate | annual premium rate, e.g. 0.05 for 5% p.a. |
dayCounter | day count convention for the premium rate |
recoveryRate | recovery rate as a fraction |
upfrontPremiumRate | premium as a tranche notional fraction |
yieldTS | yield term structure handle |
nBuckets | number of distribution buckets |
integrationStep | time step for integrating over one premium period; if larger than premium period length, a single step is taken |
Definition at line 28 of file cdo.cpp.
|
overridevirtual |
returns whether the instrument might have value greater than zero.
Implements Instrument.
Definition at line 84 of file cdo.cpp.
Rate fairPremium | ( | ) | const |
Rate premiumValue | ( | ) | const |
Rate protectionValue | ( | ) | const |
Size error | ( | ) | const |
|
overrideprivatevirtual |
This method must leave the instrument in a consistent state when the expiration condition is met.
Reimplemented from Instrument.
Definition at line 90 of file cdo.cpp.
|
overrideprivatevirtual |
This method must implement any calculations which must be (re)done in order to calculate the desired results.
Implements LazyObject.
Definition at line 118 of file cdo.cpp.
|
private |
|
private |
|
private |
|
private |