Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
IndexCdsOptionBaseEngine Class Referenceabstract

#include <qle/pricingengines/indexcdsoptionbaseengine.hpp>

+ Inheritance diagram for IndexCdsOptionBaseEngine:
+ Collaboration diagram for IndexCdsOptionBaseEngine:

Public Member Functions

 IndexCdsOptionBaseEngine (const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > &probability, QuantLib::Real recovery, const Handle< YieldTermStructure > &discountSwapCurrency, const Handle< YieldTermStructure > &discountTradeCollateral, const QuantLib::Handle< QuantExt::CreditVolCurve > &volatility)
 Constructor taking a default probability term structure bootstrapped from the index spreads. More...
 
 IndexCdsOptionBaseEngine (const std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > &probabilities, const std::vector< QuantLib::Real > &recoveries, const Handle< YieldTermStructure > &discountSwapCurrency, const Handle< YieldTermStructure > &discountTradeCollateral, const QuantLib::Handle< QuantExt::CreditVolCurve > &volatility, QuantLib::Real indexRecovery=QuantLib::Null< QuantLib::Real >())
 
Inspectors
const std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > & probabilities () const
 
const std::vector< QuantLib::Real > & recoveries () const
 
const QuantLib::Handle< QuantLib::YieldTermStructure > discountSwapCurrency () const
 
const QuantLib::Handle< QuantLib::YieldTermStructure > discountTradeCollateral () const
 
const QuantLib::Handle< QuantExt::CreditVolCurvevolatility () const
 

Instrument interface

std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > probabilities_
 Store inputs. More...
 
std::vector< QuantLib::Real > recoveries_
 
QuantLib::Handle< QuantLib::YieldTermStructure > discountSwapCurrency_
 
QuantLib::Handle< QuantLib::YieldTermStructure > discountTradeCollateral_
 
QuantLib::Handle< QuantExt::CreditVolCurvevolatility_
 
QuantLib::Real indexRecovery_
 Assumed index recovery used in the flat strike spread curve calculation if provided. More...
 
std::vector< QuantLib::Real > notionals_
 Store the underlying index CDS notional(s) during calculation. More...
 
void calculate () const override
 
virtual void doCalc () const =0
 Engine specific calculation. More...
 
void registerWithMarket ()
 Register with market data. More...
 
QuantLib::Real fep () const
 Calculate the discounted value of the front end protection. More...
 

Detailed Description

Definition at line 31 of file indexcdsoptionbaseengine.hpp.

Constructor & Destructor Documentation

◆ IndexCdsOptionBaseEngine() [1/2]

IndexCdsOptionBaseEngine ( const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > &  probability,
QuantLib::Real  recovery,
const Handle< YieldTermStructure > &  discountSwapCurrency,
const Handle< YieldTermStructure > &  discountTradeCollateral,
const QuantLib::Handle< QuantExt::CreditVolCurve > &  volatility 
)

Constructor taking a default probability term structure bootstrapped from the index spreads.

◆ IndexCdsOptionBaseEngine() [2/2]

IndexCdsOptionBaseEngine ( const std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > &  probabilities,
const std::vector< QuantLib::Real > &  recoveries,
const Handle< YieldTermStructure > &  discountSwapCurrency,
const Handle< YieldTermStructure > &  discountTradeCollateral,
const QuantLib::Handle< QuantExt::CreditVolCurve > &  volatility,
QuantLib::Real  indexRecovery = QuantLib::Null< QuantLib::Real >() 
)

Constructor taking a vector of default probability term structures bootstrapped from the index constituent spread curves and a vector of associated recovery rates.

Member Function Documentation

◆ probabilities()

const vector< Handle< DefaultProbabilityTermStructure > > & probabilities ( ) const

Definition at line 69 of file indexcdsoptionbaseengine.cpp.

69 {
70 return probabilities_;
71}
std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > probabilities_
Store inputs.

◆ recoveries()

const vector< Real > & recoveries ( ) const

Definition at line 73 of file indexcdsoptionbaseengine.cpp.

73{ return recoveries_; }
std::vector< QuantLib::Real > recoveries_

◆ discountSwapCurrency()

const Handle< YieldTermStructure > discountSwapCurrency ( ) const

Definition at line 75 of file indexcdsoptionbaseengine.cpp.

75 {
77}
QuantLib::Handle< QuantLib::YieldTermStructure > discountSwapCurrency_

◆ discountTradeCollateral()

const Handle< YieldTermStructure > discountTradeCollateral ( ) const

Definition at line 79 of file indexcdsoptionbaseengine.cpp.

79 {
81}
QuantLib::Handle< QuantLib::YieldTermStructure > discountTradeCollateral_

◆ volatility()

const Handle< QuantExt::CreditVolCurve > volatility ( ) const

Definition at line 83 of file indexcdsoptionbaseengine.cpp.

83{ return volatility_; }
QuantLib::Handle< QuantExt::CreditVolCurve > volatility_
+ Here is the caller graph for this function:

◆ calculate()

void calculate ( ) const
override

Definition at line 85 of file indexcdsoptionbaseengine.cpp.

85 {
86
87 // Underlying index CDS
88 const auto& cds = *arguments_.swap;
89
90 // If given constituent curves, store constituent notionals. Otherwise, store top level notional.
91 if (probabilities_.size() > 1) {
92 notionals_ = cds.underlyingNotionals();
93 QL_REQUIRE(probabilities_.size() == notionals_.size(), "IndexCdsOptionBaseEngine: mismatch between size"
94 << " of probabilities (" << probabilities_.size()
95 << ") and notionals (" << notionals_.size() << ").");
96 } else {
97 notionals_ = {cds.notional()};
98 }
99
100 // Get additional results of underlying index CDS.
101 cds.NPV();
102 results_.additionalResults = cds.additionalResults();
103
104 // call engine-specific calculation
105 doCalc();
106}
const Instrument::results * results_
Definition: cdsoption.cpp:81
virtual void doCalc() const =0
Engine specific calculation.
std::vector< QuantLib::Real > notionals_
Store the underlying index CDS notional(s) during calculation.
Swap::arguments * arguments_

◆ doCalc()

virtual void doCalc ( ) const
protectedpure virtual

Engine specific calculation.

Implemented in BlackIndexCdsOptionEngine, and NumericalIntegrationIndexCdsOptionEngine.

◆ registerWithMarket()

void registerWithMarket ( )
protected

Register with market data.

Definition at line 134 of file indexcdsoptionbaseengine.cpp.

134 {
135 for (const auto& p : probabilities_)
136 registerWith(p);
137 registerWith(discountTradeCollateral_);
138 registerWith(discountSwapCurrency_);
139 registerWith(volatility_);
140}

◆ fep()

Real fep ( ) const
protected

Calculate the discounted value of the front end protection.

Definition at line 108 of file indexcdsoptionbaseengine.cpp.

108 {
109
110 // Exercise date
111 const Date& exerciseDate = arguments_.exercise->dates().front();
112
113 // Realised FEP
114 results_.additionalResults["realisedFEP"] = arguments_.realisedFep;
115
116 // Unrealised FEP
117 Real fep = 0.0;
118 for (Size i = 0; i < probabilities_.size(); ++i) {
119 fep += (1 - recoveries_[i]) * probabilities_[i]->defaultProbability(exerciseDate) * notionals_[i];
120 }
121 results_.additionalResults["UnrealisedFEP"] = fep;
122
123 // Total FEP
124 fep += arguments_.realisedFep;
125 results_.additionalResults["FEP"] = fep;
126
127 // Discounted FEP
128 fep *= discountTradeCollateral_->discount(exerciseDate);
129 results_.additionalResults["discountedFEP"] = fep;
130
131 return fep;
132}
QuantLib::Real fep() const
Calculate the discounted value of the front end protection.
+ Here is the caller graph for this function:

Member Data Documentation

◆ probabilities_

std::vector<QuantLib::Handle<QuantLib::DefaultProbabilityTermStructure> > probabilities_
protected

Store inputs.

Definition at line 74 of file indexcdsoptionbaseengine.hpp.

◆ recoveries_

std::vector<QuantLib::Real> recoveries_
protected

Definition at line 75 of file indexcdsoptionbaseengine.hpp.

◆ discountSwapCurrency_

QuantLib::Handle<QuantLib::YieldTermStructure> discountSwapCurrency_
protected

Definition at line 76 of file indexcdsoptionbaseengine.hpp.

◆ discountTradeCollateral_

QuantLib::Handle<QuantLib::YieldTermStructure> discountTradeCollateral_
protected

Definition at line 77 of file indexcdsoptionbaseengine.hpp.

◆ volatility_

QuantLib::Handle<QuantExt::CreditVolCurve> volatility_
protected

Definition at line 78 of file indexcdsoptionbaseengine.hpp.

◆ indexRecovery_

QuantLib::Real indexRecovery_
protected

Assumed index recovery used in the flat strike spread curve calculation if provided.

Definition at line 81 of file indexcdsoptionbaseengine.hpp.

◆ notionals_

std::vector<QuantLib::Real> notionals_
mutableprotected

Store the underlying index CDS notional(s) during calculation.

Definition at line 84 of file indexcdsoptionbaseengine.hpp.