22#include <ql/cashflows/fixedratecoupon.hpp>
23#include <ql/instruments/claim.hpp>
24#include <ql/pricingengines/credit/midpointcdsengine.hpp>
25#include <ql/termstructures/yieldtermstructure.hpp>
26#include <ql/optional.hpp>
34 const ext::optional<bool>& includeSettlementDateFlows)
35 : probability_(
std::move(probability)), recoveryRate_(recoveryRate),
36 discountCurve_(
std::move(discountCurve)),
37 includeSettlementDateFlows_(includeSettlementDateFlows) {
44 "no discount term structure set");
46 "no probability term structure set");
77 ext::shared_ptr<FixedRateCoupon> coupon =
78 ext::dynamic_pointer_cast<FixedRateCoupon>(
arguments_.
leg[i]);
84 Date paymentDate = coupon->date(),
85 startDate = coupon->accrualStartDate(),
86 endDate = coupon->accrualEndDate();
90 Date effectiveStartDate =
91 (startDate <= today && today <= endDate) ? today : startDate;
93 effectiveStartDate + (endDate-effectiveStartDate)/2;
103 S * coupon->amount() *
109 P * coupon->accruedAmount(defaultDate) *
114 P * coupon->amount() *
132 Real upfrontSign = 1.0;
144 QL_FAIL(
"unknown protection side");
169 static const Rate basisPoint = 1.0e-4;
ext::shared_ptr< Claim > claim
ext::shared_ptr< SimpleCashFlow > accrualRebate
ext::optional< Rate > upfront
ext::shared_ptr< SimpleCashFlow > upfrontPayment
CreditDefaultSwap::results results_
CreditDefaultSwap::arguments arguments_
Shared handle to an observable.
Handle< YieldTermStructure > discountCurve_
Handle< DefaultProbabilityTermStructure > probability_
ext::optional< bool > includeSettlementDateFlows_
void calculate() const override
MidPointCdsEngine(Handle< DefaultProbabilityTermStructure >, Real recoveryRate, Handle< YieldTermStructure > discountCurve, const ext::optional< bool > &includeSettlementDateFlows=ext::nullopt)
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
Real Probability
probability
std::size_t Size
size of a container