21#include <ql/instruments/claim.hpp>
26 Real recoveryRate,
const Handle<YieldTermStructure>& discountCurve,
27 boost::optional<bool> includeSettlementDateFlows)
29 recoveryRate_(recoveryRate), useUnderlyingCurves_(false) {
30 registerWith(discountCurve_);
35 const std::vector<Handle<DefaultProbabilityTermStructure>>& underlyingProbability,
36 const std::vector<Real>& underlyingRecoveryRate,
const Handle<YieldTermStructure>& discountCurve,
37 boost::optional<bool> includeSettlementDateFlows)
38 :
MidPointCdsEngineBase(discountCurve, includeSettlementDateFlows), underlyingProbability_(underlyingProbability),
39 underlyingRecoveryRate_(underlyingRecoveryRate), useUnderlyingCurves_(true) {
40 registerWith(discountCurve_);
48 Real
sum = 0.0, sumNotional = 0.0;
51 sumNotional +=
arguments_.underlyingNotionals[i];
53 return sum / sumNotional;
59 Real
sum = 0.0, sumNotional = 0.0;
62 sumNotional +=
arguments_.underlyingNotionals[i];
64 return sum / sumNotional;
68 const Real notional)
const {
72 Real
sum = 0.0, sumNotional = 0.0;
76 sumNotional +=
arguments_.underlyingNotionals[i];
78 return sum / sumNotional * notional;
82 QL_REQUIRE(!discountCurve_.empty(),
"no discount term structure set");
86 "number of underlyings (" <<
arguments_.underlyingNotionals.size()
93 QL_REQUIRE(!
probability_.empty(),
"no probability term structure set");
const Instrument::results * results_
Real survivalProbability(const Date &d) const override
Handle< DefaultProbabilityTermStructure > probability_
MidPointIndexCdsEngine(const Handle< DefaultProbabilityTermStructure > &, Real recoveryRate, const Handle< YieldTermStructure > &discountCurve, boost::optional< bool > includeSettlementDateFlows=boost::none)
void calculate() const override
const bool useUnderlyingCurves_
const std::vector< Handle< DefaultProbabilityTermStructure > > underlyingProbability_
Real expectedLoss(const Date &defaultDate, const Date &d1, const Date &d2, const Real notional) const override
const std::vector< Real > underlyingRecoveryRate_
Real defaultProbability(const Date &d1, const Date &d2) const override
Mid-point engine for credit default swaps.
Real sum(const Cash &c, const Cash &d)
Swap::arguments * arguments_