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

CDS option helper. More...

#include <qle/models/cdsoptionhelper.hpp>

+ Inheritance diagram for CdsOptionHelper:
+ Collaboration diagram for CdsOptionHelper:

Public Member Functions

 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)
 
virtual void addTimesTo (std::list< Time > &times) const override
 
virtual Real modelValue () const override
 
virtual Real blackPrice (Volatility volatility) const override
 
QuantLib::ext::shared_ptr< CreditDefaultSwap > underlying () const
 
QuantLib::ext::shared_ptr< QuantExt::CdsOptionoption () const
 

Private Attributes

Handle< YieldTermStructure > termStructure_
 
QuantLib::ext::shared_ptr< CreditDefaultSwap > cds_
 
QuantLib::ext::shared_ptr< QuantExt::CdsOptionoption_
 
QuantLib::ext::shared_ptr< SimpleQuote > blackVol_
 
QuantLib::ext::shared_ptr< PricingEngine > blackEngine_
 

Detailed Description

CDS option helper.

Definition at line 39 of file cdsoptionhelper.hpp.

Constructor & Destructor Documentation

◆ CdsOptionHelper()

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 
)

Definition at line 32 of file cdsoptionhelper.cpp.

42 : BlackCalibrationHelper(volatility, errorType), termStructure_(termStructure),
43 blackVol_(QuantLib::ext::make_shared<SimpleQuote>(0.0)) {
44
45 QuantLib::ext::shared_ptr<PricingEngine> cdsEngine =
46 QuantLib::ext::make_shared<QuantExt::MidPointCdsEngine>(probability, recoveryRate, termStructure);
47
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));
53 else
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);
58
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));
64 else
65 cds_ = QuantLib::ext::shared_ptr<CreditDefaultSwap>(
66 new CreditDefaultSwap(side, 1.0, upfront, strike, schedule, paymentConvention, dayCounter, settlesAccrual,
67 protectionPaymentTime, protectionStart, upfrontDate, claim));
68
69 cds_->setPricingEngine(cdsEngine);
70
71 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<EuropeanExercise>(exerciseDate);
72
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()));
76
77 blackEngine_ = QuantLib::ext::make_shared<BlackCdsOptionEngine>(
78 probability, recoveryRate, termStructure, Handle<CreditVolCurve>(QuantLib::ext::make_shared<CreditVolCurveWrapper>(h)));
79}
QuantLib::ext::shared_ptr< QuantExt::CdsOption > option_
QuantLib::ext::shared_ptr< CreditDefaultSwap > cds_
QuantLib::ext::shared_ptr< PricingEngine > blackEngine_
QuantLib::ext::shared_ptr< SimpleQuote > blackVol_
Handle< YieldTermStructure > termStructure_

Member Function Documentation

◆ addTimesTo()

virtual void addTimesTo ( std::list< Time > &  times) const
overridevirtual

Definition at line 53 of file cdsoptionhelper.hpp.

53{}

◆ modelValue()

Real modelValue ( ) const
overridevirtual

Definition at line 81 of file cdsoptionhelper.cpp.

81 {
82 calculate();
83 option_->setPricingEngine(engine_);
84 return option_->NPV();
85}
QuantLib::ext::shared_ptr< PricingEngine > engine_
Definition: cdsoption.cpp:78

◆ blackPrice()

Real blackPrice ( Volatility  volatility) const
overridevirtual

Definition at line 87 of file cdsoptionhelper.cpp.

87 {
88 calculate();
89 blackVol_->setValue(sigma);
90 option_->setPricingEngine(blackEngine_);
91 Real value = option_->NPV();
92 option_->setPricingEngine(engine_);
93 return value;
94}

◆ underlying()

QuantLib::ext::shared_ptr< CreditDefaultSwap > underlying ( ) const

Definition at line 57 of file cdsoptionhelper.hpp.

57{ return cds_; }

◆ option()

QuantLib::ext::shared_ptr< QuantExt::CdsOption > option ( ) const

Definition at line 58 of file cdsoptionhelper.hpp.

58{ return option_; }

Member Data Documentation

◆ termStructure_

Handle<YieldTermStructure> termStructure_
private

Definition at line 61 of file cdsoptionhelper.hpp.

◆ cds_

QuantLib::ext::shared_ptr<CreditDefaultSwap> cds_
private

Definition at line 62 of file cdsoptionhelper.hpp.

◆ option_

QuantLib::ext::shared_ptr<QuantExt::CdsOption> option_
private

Definition at line 63 of file cdsoptionhelper.hpp.

◆ blackVol_

QuantLib::ext::shared_ptr<SimpleQuote> blackVol_
private

Definition at line 64 of file cdsoptionhelper.hpp.

◆ blackEngine_

QuantLib::ext::shared_ptr<PricingEngine> blackEngine_
private

Definition at line 65 of file cdsoptionhelper.hpp.