QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
NthToDefault Class Reference

N-th to default swap. More...

#include <nthtodefault.hpp>

+ Inheritance diagram for NthToDefault:
+ Collaboration diagram for NthToDefault:

Classes

class  arguments
 
class  engine
 NTD base engine. More...
 
class  results
 

Public Member Functions

 NthToDefault (const ext::shared_ptr< Basket > &basket, Size n, Protection::Side side, Schedule premiumSchedule, Rate upfrontRate, Rate premiumRate, const DayCounter &dayCounter, Real nominal, bool settlePremiumAccrual)
 This product is 'digital'; the basket might be tranched but this is. More...
 
bool isExpired () const override
 returns whether the instrument might have value greater than zero. More...
 
Rate premium () const
 
Real nominal () const
 
DayCounter dayCounter () const
 
Protection::Side side () const
 
Size rank () const
 
Size basketSize () const
 
const Datematurity () const
 
const ext::shared_ptr< Basket > & basket () const
 
Rate fairPremium () const
 
Real premiumLegNPV () const
 
Real protectionLegNPV () const
 
Real errorEstimate () const
 
void setupArguments (PricingEngine::arguments *) const override
 
void fetchResults (const PricingEngine::results *) const override
 
- 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 DatevaluationDate () 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...
 
- 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 &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (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
 

Private Attributes

ext::shared_ptr< Basketbasket_
 
Size n_
 
Protection::Side side_
 
Real nominal_
 
Schedule premiumSchedule_
 
Rate premiumRate_
 
Rate upfrontRate_
 
DayCounter dayCounter_
 
bool settlePremiumAccrual_
 
Leg premiumLeg_
 
Rate premiumValue_
 
Real protectionValue_
 
Real upfrontPremiumValue_
 
Real fairPremium_
 
Real errorEstimate_
 

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< PricingEngineengine_
 
- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 

Detailed Description

N-th to default swap.

A NTD instrument exchanges protection against the nth default in a basket of underlying credits for premium payments based on the protected notional amount.

The pricing is analogous to the pricing of a CDS instrument which represents protection against default of a single underlying credit. The only difference is the calculation of the probability of default. In the CDS case, it is the probabilty of single name default; in the NTD case the probability of at least N defaults in the portfolio of underlying credits.

This probability is computed using the algorithm 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 algorithm allows for varying probability of default across the basket. Otherwise, for identical probabilities of default, the probability of n defaults is given by the binomial distribution.

Default correlation is modeled using a one-factor Gaussian copula approach.

The class is tested against data in Hull-White (see reference above.)

Definition at line 70 of file nthtodefault.hpp.

Constructor & Destructor Documentation

◆ NthToDefault()

NthToDefault ( const ext::shared_ptr< Basket > &  basket,
Size  n,
Protection::Side  side,
Schedule  premiumSchedule,
Rate  upfrontRate,
Rate  premiumRate,
const DayCounter dayCounter,
Real  nominal,
bool  settlePremiumAccrual 
)

This product is 'digital'; the basket might be tranched but this is.

Definition at line 31 of file nthtodefault.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
overridevirtual

returns whether the instrument might have value greater than zero.

Implements Instrument.

Definition at line 68 of file nthtodefault.cpp.

+ Here is the call graph for this function:

◆ premium()

Rate premium ( ) const

Definition at line 91 of file nthtodefault.hpp.

◆ nominal()

Real nominal ( ) const

Definition at line 92 of file nthtodefault.hpp.

+ Here is the caller graph for this function:

◆ dayCounter()

DayCounter dayCounter ( ) const

Definition at line 93 of file nthtodefault.hpp.

+ Here is the caller graph for this function:

◆ side()

Protection::Side side ( ) const

Definition at line 94 of file nthtodefault.hpp.

+ Here is the caller graph for this function:

◆ rank()

Size rank ( ) const

Definition at line 95 of file nthtodefault.hpp.

◆ basketSize()

Size basketSize ( ) const

Definition at line 66 of file nthtodefault.cpp.

◆ maturity()

const Date & maturity ( ) const

Definition at line 98 of file nthtodefault.hpp.

+ Here is the call graph for this function:

◆ basket()

const ext::shared_ptr< Basket > & basket ( ) const

Definition at line 100 of file nthtodefault.hpp.

+ Here is the caller graph for this function:

◆ fairPremium()

Rate fairPremium ( ) const

Definition at line 72 of file nthtodefault.cpp.

+ Here is the call graph for this function:

◆ premiumLegNPV()

Real premiumLegNPV ( ) const

Definition at line 79 of file nthtodefault.cpp.

+ Here is the call graph for this function:

◆ protectionLegNPV()

Real protectionLegNPV ( ) const

Definition at line 88 of file nthtodefault.cpp.

+ Here is the call graph for this function:

◆ errorEstimate()

Real errorEstimate ( ) const

Definition at line 95 of file nthtodefault.cpp.

+ Here is the call graph for this function:

◆ setupArguments()

void setupArguments ( PricingEngine::arguments ) const
overridevirtual

When a derived argument structure is defined for an instrument, this method should be overridden to fill it. This is mandatory in case a pricing engine is used.

Reimplemented from Instrument.

Definition at line 113 of file nthtodefault.cpp.

◆ fetchResults()

void fetchResults ( const PricingEngine::results r) const
overridevirtual

When a derived result structure is defined for an instrument, this method should be overridden to read from it. This is mandatory in case a pricing engine is used.

Reimplemented from Instrument.

Definition at line 126 of file nthtodefault.cpp.

+ Here is the call graph for this function:

◆ setupExpired()

void setupExpired ( ) const
overrideprivatevirtual

This method must leave the instrument in a consistent state when the expiration condition is met.

Reimplemented from Instrument.

Definition at line 103 of file nthtodefault.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ basket_

ext::shared_ptr<Basket> basket_
private

Definition at line 114 of file nthtodefault.hpp.

◆ n_

Size n_
private

Definition at line 115 of file nthtodefault.hpp.

◆ side_

Protection::Side side_
private

Definition at line 116 of file nthtodefault.hpp.

◆ nominal_

Real nominal_
private

Definition at line 117 of file nthtodefault.hpp.

◆ premiumSchedule_

Schedule premiumSchedule_
private

Definition at line 118 of file nthtodefault.hpp.

◆ premiumRate_

Rate premiumRate_
private

Definition at line 119 of file nthtodefault.hpp.

◆ upfrontRate_

Rate upfrontRate_
private

Definition at line 120 of file nthtodefault.hpp.

◆ dayCounter_

DayCounter dayCounter_
private

Definition at line 121 of file nthtodefault.hpp.

◆ settlePremiumAccrual_

bool settlePremiumAccrual_
private

Definition at line 122 of file nthtodefault.hpp.

◆ premiumLeg_

Leg premiumLeg_
private

Definition at line 124 of file nthtodefault.hpp.

◆ premiumValue_

Rate premiumValue_
mutableprivate

Definition at line 127 of file nthtodefault.hpp.

◆ protectionValue_

Real protectionValue_
mutableprivate

Definition at line 128 of file nthtodefault.hpp.

◆ upfrontPremiumValue_

Real upfrontPremiumValue_
mutableprivate

Definition at line 129 of file nthtodefault.hpp.

◆ fairPremium_

Real fairPremium_
mutableprivate

Definition at line 130 of file nthtodefault.hpp.

◆ errorEstimate_

Real errorEstimate_
mutableprivate

Definition at line 131 of file nthtodefault.hpp.