Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MidPointCdsEngineMultiState Class Reference

#include <qle/pricingengines/midpointcdsenginemultistate.hpp>

+ Inheritance diagram for MidPointCdsEngineMultiState:
+ Collaboration diagram for MidPointCdsEngineMultiState:

Public Member Functions

 MidPointCdsEngineMultiState (const std::vector< Handle< DefaultProbabilityTermStructure > > &defaultCurves, const std::vector< Handle< Quote > > recoveryRates, const Handle< YieldTermStructure > &discountCurve, const Size mainResultState, const boost::optional< bool > includeSettlementDateFlows=boost::none)
 
void calculate () const
 
Handle< YieldTermStructure > discountCurve () const
 
const std::vector< Handle< DefaultProbabilityTermStructure > > & defaultCurves () const
 
const std::vector< Handle< Quote > > & recoveryRates () const
 

Private Member Functions

void linkCurves (Size i) const
 
Real calculateDefaultValue () const
 

Private Attributes

std::vector< Handle< DefaultProbabilityTermStructure > > defaultCurves_
 
std::vector< Handle< Quote > > recoveryRates_
 
Size mainResultState_
 

Detailed Description

The engine takes a vector of default curves and recovery rates. For the given main result state it will produce the same results as the MidPointCdsEngine. In addition a result with label "stateNPV" is produced containing the NPV for each given default curve / recovery rate and an additional entry with a default value w.r.t. the last given recovery rate in the vector.

Definition at line 36 of file midpointcdsenginemultistate.hpp.

Constructor & Destructor Documentation

◆ MidPointCdsEngineMultiState()

MidPointCdsEngineMultiState ( const std::vector< Handle< DefaultProbabilityTermStructure > > &  defaultCurves,
const std::vector< Handle< Quote > >  recoveryRates,
const Handle< YieldTermStructure > &  discountCurve,
const Size  mainResultState,
const boost::optional< bool includeSettlementDateFlows = boost::none 
)

Definition at line 29 of file midpointcdsenginemultistate.cpp.

33 : MidPointCdsEngine(Handle<DefaultProbabilityTermStructure>(), 0.0, discountCurve, includeSettlementDateFlows),
35 QL_REQUIRE(defaultCurves.size() == recoveryRates.size(), "MidPointCdsEngineMultiState: number of default curves ("
36 << defaultCurves_.size()
37 << ") must match number of recovery rates ("
38 << recoveryRates_.size() << ")");
39 QL_REQUIRE(!defaultCurves.empty(), "MidPointCdsEngineMultiState: no default curves / recovery rates given");
40 for (auto const& h : defaultCurves_) {
41 registerWith(h);
42 }
43 for (auto const& r : recoveryRates_) {
44 registerWith(r);
45 }
46 QL_REQUIRE(mainResultState < defaultCurves.size(), "MidPointCdsEngineMultiState: mainResultState ("
47 << mainResultState << ") out of range 0..."
48 << defaultCurves.size() - 1);
49}
Handle< YieldTermStructure > discountCurve() const
const std::vector< Handle< Quote > > & recoveryRates() const
std::vector< Handle< DefaultProbabilityTermStructure > > defaultCurves_
const std::vector< Handle< DefaultProbabilityTermStructure > > & defaultCurves() const
+ Here is the call graph for this function:

Member Function Documentation

◆ calculate()

void calculate ( ) const

Definition at line 56 of file midpointcdsenginemultistate.cpp.

56 {
57
58 // calculate all states except the main states
59
60 std::vector<Real> values(defaultCurves_.size() + 1);
61 for (Size i = 0; i < defaultCurves_.size(); ++i) {
62 if (i == mainResultState_)
63 continue;
64 linkCurves(i);
65 MidPointCdsEngine::calculate();
66 values[i] = results_.value;
67 }
68
69 // calculate the main state last to keep the results from this calculation
70
72 MidPointCdsEngine::calculate();
73 values[mainResultState_] = results_.value;
74
75 // calculate the default state
76
77 values.back() = calculateDefaultValue();
78
79 // set additional result
80
81 results_.additionalResults["stateNpv"] = values;
82}
const Instrument::results * results_
Definition: cdsoption.cpp:81
+ Here is the call graph for this function:

◆ discountCurve()

Handle< YieldTermStructure > discountCurve ( ) const

Definition at line 44 of file midpointcdsenginemultistate.hpp.

44{ return discountCurve_; };

◆ defaultCurves()

const std::vector< Handle< DefaultProbabilityTermStructure > > & defaultCurves ( ) const

Definition at line 45 of file midpointcdsenginemultistate.hpp.

45{ return defaultCurves_; };
+ Here is the caller graph for this function:

◆ recoveryRates()

const std::vector< Handle< Quote > > & recoveryRates ( ) const

Definition at line 46 of file midpointcdsenginemultistate.hpp.

46{ return recoveryRates_; };
+ Here is the caller graph for this function:

◆ linkCurves()

void linkCurves ( Size  i) const
private

Definition at line 51 of file midpointcdsenginemultistate.cpp.

51 {
52 probability_ = defaultCurves_[i];
53 recoveryRate_ = recoveryRates_[i]->value();
54}
+ Here is the caller graph for this function:

◆ calculateDefaultValue()

Real calculateDefaultValue ( ) const
private

Definition at line 84 of file midpointcdsenginemultistate.cpp.

84 {
85 Date defaultDate = discountCurve_->referenceDate();
86 Real phi = arguments_.side == Protection::Seller ? -1.0 : 1.0;
87 return phi * arguments_.claim->amount(defaultDate, arguments_.notional, recoveryRates_.back()->value());
88}
Swap::arguments * arguments_
+ Here is the caller graph for this function:

Member Data Documentation

◆ defaultCurves_

std::vector<Handle<DefaultProbabilityTermStructure> > defaultCurves_
private

Definition at line 52 of file midpointcdsenginemultistate.hpp.

◆ recoveryRates_

std::vector<Handle<Quote> > recoveryRates_
private

Definition at line 53 of file midpointcdsenginemultistate.hpp.

◆ mainResultState_

Size mainResultState_
private

Definition at line 54 of file midpointcdsenginemultistate.hpp.