22#include <ql/pricingengines/credit/midpointcdsengine.hpp>
23#include <ql/exercise.hpp>
24#include <ql/quotes/simplequote.hpp>
25#include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp>
26#include <ql/time/schedule.hpp>
28#include <boost/make_shared.hpp>
33 const Schedule& schedule,
const BusinessDayConvention paymentConvention,
34 const DayCounter& dayCounter,
35 const Handle<DefaultProbabilityTermStructure>& probability,
const Real recoveryRate,
36 const Handle<YieldTermStructure>& termStructure,
const Rate spread,
const Rate upfront,
37 const bool settlesAccrual,
38 const CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime,
39 const Date protectionStart,
const Date upfrontDate,
40 const QuantLib::ext::shared_ptr<Claim>& claim,
41 const BlackCalibrationHelper::CalibrationErrorType errorType)
43 blackVol_(
QuantLib::ext::make_shared<SimpleQuote>(0.0)) {
45 QuantLib::ext::shared_ptr<PricingEngine> cdsEngine =
46 QuantLib::ext::make_shared<QuantExt::MidPointCdsEngine>(probability, recoveryRate, termStructure);
48 QuantLib::ext::shared_ptr<CreditDefaultSwap> tmp;
49 if (upfront == Null<Real>())
50 tmp = QuantLib::ext::shared_ptr<CreditDefaultSwap>(
51 new CreditDefaultSwap(side, 1.0, 0.02, schedule, paymentConvention, dayCounter, settlesAccrual,
52 protectionPaymentTime, protectionStart, claim));
54 tmp = QuantLib::ext::shared_ptr<CreditDefaultSwap>(
55 new CreditDefaultSwap(side, 1.0, upfront, 0.02, schedule, paymentConvention, dayCounter, settlesAccrual,
56 protectionPaymentTime, protectionStart, upfrontDate, claim));
57 tmp->setPricingEngine(cdsEngine);
59 Real strike = spread == Null<Real>() ? tmp->fairSpreadClean() : spread;
60 if (upfront == Null<Real>())
61 cds_ = QuantLib::ext::shared_ptr<CreditDefaultSwap>(
62 new CreditDefaultSwap(side, 1.0, strike, schedule, paymentConvention, dayCounter, settlesAccrual,
63 protectionPaymentTime, protectionStart, claim));
65 cds_ = QuantLib::ext::shared_ptr<CreditDefaultSwap>(
66 new CreditDefaultSwap(side, 1.0, upfront, strike, schedule, paymentConvention, dayCounter, settlesAccrual,
67 protectionPaymentTime, protectionStart, upfrontDate, claim));
69 cds_->setPricingEngine(cdsEngine);
71 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<EuropeanExercise>(exerciseDate);
73 option_ = QuantLib::ext::make_shared<CdsOption>(
cds_, exercise,
true);
74 Handle<BlackVolTermStructure> h(
75 QuantLib::ext::make_shared<BlackConstantVol>(0, NullCalendar(), Handle<Quote>(
blackVol_), Actual365Fixed()));
77 blackEngine_ = QuantLib::ext::make_shared<BlackCdsOptionEngine>(
78 probability, recoveryRate, termStructure, Handle<CreditVolCurve>(QuantLib::ext::make_shared<CreditVolCurveWrapper>(h)));
Black credit default swap option engine.
QuantLib::ext::shared_ptr< PricingEngine > engine_
cds option calibration helper
QuantLib::ext::shared_ptr< QuantExt::CdsOption > option_
QuantLib::ext::shared_ptr< CreditDefaultSwap > cds_
virtual Real blackPrice(Volatility volatility) const override
QuantLib::ext::shared_ptr< PricingEngine > blackEngine_
virtual Real modelValue() const override
QuantLib::ext::shared_ptr< SimpleQuote > blackVol_
CdsOptionHelper(const Date &exerciseDate, const Handle< Quote > &volatility, const Protection::Side side, const Schedule &schedule, const BusinessDayConvention paymentConvention, const DayCounter &dayCounter, const Handle< DefaultProbabilityTermStructure > &probability, const Real recoveryRate, const Handle< YieldTermStructure > &termStructure, const Rate spread=Null< Rate >(), const Rate upfront=Null< Rate >(), const bool settlesAccrual=true, const CreditDefaultSwap::ProtectionPaymentTime proteectionPaymentTime=CreditDefaultSwap::ProtectionPaymentTime::atDefault, const Date protectionStart=Date(), const Date upfrontDate=Date(), const QuantLib::ext::shared_ptr< Claim > &claim=QuantLib::ext::shared_ptr< Claim >(), const BlackCalibrationHelper::CalibrationErrorType errorType=BlackCalibrationHelper::RelativePriceError)