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
MidPointIndexCdsEngine Class Reference

#include <qle/pricingengines/midpointindexcdsengine.hpp>

+ Inheritance diagram for MidPointIndexCdsEngine:
+ Collaboration diagram for MidPointIndexCdsEngine:

Public Member Functions

 MidPointIndexCdsEngine (const Handle< DefaultProbabilityTermStructure > &, Real recoveryRate, const Handle< YieldTermStructure > &discountCurve, boost::optional< bool > includeSettlementDateFlows=boost::none)
 
 MidPointIndexCdsEngine (const std::vector< Handle< DefaultProbabilityTermStructure > > &, const std::vector< Real > &underlyingRecoveryRate, const Handle< YieldTermStructure > &discountCurve, boost::optional< bool > includeSettlementDateFlows=boost::none)
 
void calculate () const override
 

Private Member Functions

Real survivalProbability (const Date &d) const override
 
Real defaultProbability (const Date &d1, const Date &d2) const override
 
Real expectedLoss (const Date &defaultDate, const Date &d1, const Date &d2, const Real notional) const override
 

Private Attributes

Handle< DefaultProbabilityTermStructure > probability_
 
Real recoveryRate_
 
const std::vector< Handle< DefaultProbabilityTermStructure > > underlyingProbability_
 
const std::vector< Real > underlyingRecoveryRate_
 
const bool useUnderlyingCurves_
 

Detailed Description

Definition at line 33 of file midpointindexcdsengine.hpp.

Constructor & Destructor Documentation

◆ MidPointIndexCdsEngine() [1/2]

MidPointIndexCdsEngine ( const Handle< DefaultProbabilityTermStructure > &  probability,
Real  recoveryRate,
const Handle< YieldTermStructure > &  discountCurve,
boost::optional< bool includeSettlementDateFlows = boost::none 
)

Definition at line 25 of file midpointindexcdsengine.cpp.

28 : MidPointCdsEngineBase(discountCurve, includeSettlementDateFlows), probability_(probability),
29 recoveryRate_(recoveryRate), useUnderlyingCurves_(false) {
30 registerWith(discountCurve_);
31 registerWith(probability_);
32}
Handle< DefaultProbabilityTermStructure > probability_

◆ MidPointIndexCdsEngine() [2/2]

MidPointIndexCdsEngine ( const std::vector< Handle< DefaultProbabilityTermStructure > > &  underlyingProbability,
const std::vector< Real > &  underlyingRecoveryRate,
const Handle< YieldTermStructure > &  discountCurve,
boost::optional< bool includeSettlementDateFlows = boost::none 
)

Definition at line 34 of file midpointindexcdsengine.cpp.

38 : MidPointCdsEngineBase(discountCurve, includeSettlementDateFlows), underlyingProbability_(underlyingProbability),
39 underlyingRecoveryRate_(underlyingRecoveryRate), useUnderlyingCurves_(true) {
40 registerWith(discountCurve_);
41 for (Size i = 0; i < underlyingProbability_.size(); ++i)
42 registerWith(underlyingProbability_[i]);
43}
const std::vector< Handle< DefaultProbabilityTermStructure > > underlyingProbability_
const std::vector< Real > underlyingRecoveryRate_

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 81 of file midpointindexcdsengine.cpp.

81 {
82 QL_REQUIRE(!discountCurve_.empty(), "no discount term structure set");
83 Date refDate;
85 QL_REQUIRE(underlyingProbability_.size() == arguments_.underlyingNotionals.size(),
86 "number of underlyings (" << arguments_.underlyingNotionals.size()
87 << ") does not match number of curves (" << underlyingProbability_.size()
88 << ")");
89 for (Size i = 0; i < underlyingProbability_.size(); ++i)
90 QL_REQUIRE(!underlyingProbability_.empty(), "no probability term structure set for underlying " << i);
91 refDate = underlyingProbability_.front()->referenceDate();
92 } else {
93 QL_REQUIRE(!probability_.empty(), "no probability term structure set");
94 refDate = probability_->referenceDate();
95 }
96
97 MidPointCdsEngineBase::calculate(refDate, arguments_, results_);
98}
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_

◆ survivalProbability()

Real survivalProbability ( const Date &  d) const
overrideprivate

Definition at line 45 of file midpointindexcdsengine.cpp.

45 {
47 return probability_->survivalProbability(d);
48 Real sum = 0.0, sumNotional = 0.0;
49 for (Size i = 0; i < underlyingProbability_.size(); ++i) {
50 sum += underlyingProbability_[i]->survivalProbability(d) * arguments_.underlyingNotionals[i];
51 sumNotional += arguments_.underlyingNotionals[i];
52 }
53 return sum / sumNotional;
54}
Real sum(const Cash &c, const Cash &d)
Definition: bondbasket.cpp:107
+ Here is the call graph for this function:

◆ defaultProbability()

Real defaultProbability ( const Date &  d1,
const Date &  d2 
) const
overrideprivate

Definition at line 56 of file midpointindexcdsengine.cpp.

56 {
58 return probability_->defaultProbability(d1, d2);
59 Real sum = 0.0, sumNotional = 0.0;
60 for (Size i = 0; i < underlyingProbability_.size(); ++i) {
61 sum += underlyingProbability_[i]->defaultProbability(d1, d2) * arguments_.underlyingNotionals[i];
62 sumNotional += arguments_.underlyingNotionals[i];
63 }
64 return sum / sumNotional;
65}
+ Here is the call graph for this function:

◆ expectedLoss()

Real expectedLoss ( const Date &  defaultDate,
const Date &  d1,
const Date &  d2,
const Real  notional 
) const
overrideprivate

Definition at line 67 of file midpointindexcdsengine.cpp.

68 {
70 return arguments_.claim->amount(defaultDate, notional, recoveryRate_) *
71 probability_->defaultProbability(d1, d2);
72 Real sum = 0.0, sumNotional = 0.0;
73 for (Size i = 0; i < underlyingProbability_.size(); ++i) {
74 sum += arguments_.claim->amount(defaultDate, arguments_.underlyingNotionals[i], underlyingRecoveryRate_[i]) *
75 underlyingProbability_[i]->defaultProbability(d1, d2);
76 sumNotional += arguments_.underlyingNotionals[i];
77 }
78 return sum / sumNotional * notional;
79}
+ Here is the call graph for this function:

Member Data Documentation

◆ probability_

Handle<DefaultProbabilityTermStructure> probability_
private

Definition at line 51 of file midpointindexcdsengine.hpp.

◆ recoveryRate_

Real recoveryRate_
private

Definition at line 52 of file midpointindexcdsengine.hpp.

◆ underlyingProbability_

const std::vector<Handle<DefaultProbabilityTermStructure> > underlyingProbability_
private

Definition at line 54 of file midpointindexcdsengine.hpp.

◆ underlyingRecoveryRate_

const std::vector<Real> underlyingRecoveryRate_
private

Definition at line 55 of file midpointindexcdsengine.hpp.

◆ useUnderlyingCurves_

const bool useUnderlyingCurves_
private

Definition at line 57 of file midpointindexcdsengine.hpp.