Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
CdsOption Class Reference

CDS option. More...

#include <qle/instruments/cdsoption.hpp>

+ Inheritance diagram for CdsOption:
+ Collaboration diagram for CdsOption:

Classes

class  arguments
 Arguments for CDS-option calculation More...
 
class  engine
 base class for swaption engines More...
 
class  results
 

Public Types

enum  StrikeType { Price , Spread }
 

Public Member Functions

 CdsOption (const QuantLib::ext::shared_ptr< CreditDefaultSwap > &swap, const QuantLib::ext::shared_ptr< Exercise > &exercise, bool knocksOut=true, const Real strike=Null< Real >(), const StrikeType strikeType=StrikeType::Spread)
 
Instrument interface
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 
Inspectors
const QuantLib::ext::shared_ptr< CreditDefaultSwap > & underlyingSwap () const
 

Calculations

QuantLib::ext::shared_ptr< CreditDefaultSwap > swap_
 
bool knocksOut_
 
Real strike_
 
StrikeType strikeType_
 
Real riskyAnnuity_
 
Rate atmRate () const
 
Real riskyAnnuity () const
 
Volatility impliedVolatility (Real price, const Handle< QuantLib::YieldTermStructure > &termStructure, const Handle< DefaultProbabilityTermStructure > &, Real recoveryRate, Real accuracy=1.e-4, Size maxEvaluations=100, Volatility minVol=1.0e-7, Volatility maxVol=4.0) const
 
void setupExpired () const override
 
void fetchResults (const PricingEngine::results *) const override
 

Detailed Description

CDS option.

The side of the swaption is set by choosing the side of the CDS. A receiver CDS option is a right to buy an underlying CDS selling protection and receiving a coupon. A payer CDS option is a right to buy an underlying CDS buying protection and paying coupon.

Definition at line 67 of file cdsoption.hpp.

Member Enumeration Documentation

◆ StrikeType

enum StrikeType
Enumerator
Price 
Spread 

Definition at line 73 of file cdsoption.hpp.

Constructor & Destructor Documentation

◆ CdsOption()

CdsOption ( const QuantLib::ext::shared_ptr< CreditDefaultSwap > &  swap,
const QuantLib::ext::shared_ptr< Exercise > &  exercise,
bool  knocksOut = true,
const Real  strike = Null<Real>(),
const StrikeType  strikeType = StrikeType::Spread 
)

Definition at line 85 of file cdsoption.cpp.

87 : Option(QuantLib::ext::shared_ptr<Payoff>(new NullPayoff), exercise), swap_(swap), knocksOut_(knocksOut),
88 strike_(strike == Null<Real>() ? swap_->runningSpread() : strike), strikeType_(strikeType) {
89 registerWith(swap_);
90}
QuantLib::ext::shared_ptr< CreditDefaultSwap > swap_
Definition: cdsoption.hpp:99
StrikeType strikeType_
Definition: cdsoption.hpp:102

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 92 of file cdsoption.cpp.

92{ return detail::simple_event(exercise_->dates().back()).hasOccurred(); }
+ Here is the caller graph for this function:

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 99 of file cdsoption.cpp.

99 {
100 swap_->setupArguments(args);
101 Option::setupArguments(args);
102
103 CdsOption::arguments* arguments = dynamic_cast<CdsOption::arguments*>(args);
104
105 QL_REQUIRE(arguments != 0, "wrong argument type");
106
107 arguments->swap = swap_;
108 arguments->knocksOut = knocksOut_;
109 arguments->strike = strike_;
110 arguments->strikeType = strikeType_;
111}

◆ underlyingSwap()

const QuantLib::ext::shared_ptr< CreditDefaultSwap > & underlyingSwap ( ) const

Definition at line 86 of file cdsoption.hpp.

86{ return swap_; }

◆ atmRate()

Rate atmRate ( ) const

Definition at line 120 of file cdsoption.cpp.

120{ return swap_->fairSpreadClean(); }

◆ riskyAnnuity()

Real riskyAnnuity ( ) const

Definition at line 122 of file cdsoption.cpp.

122 {
123 calculate();
124 QL_REQUIRE(riskyAnnuity_ != Null<Real>(), "risky annuity not provided");
125 return riskyAnnuity_;
126}
+ Here is the caller graph for this function:

◆ impliedVolatility()

Volatility impliedVolatility ( Real  price,
const Handle< QuantLib::YieldTermStructure > &  termStructure,
const Handle< DefaultProbabilityTermStructure > &  ,
Real  recoveryRate,
Real  accuracy = 1.e-4,
Size  maxEvaluations = 100,
Volatility  minVol = 1.0e-7,
Volatility  maxVol = 4.0 
) const

Definition at line 128 of file cdsoption.cpp.

131 {
132 calculate();
133 QL_REQUIRE(!isExpired(), "instrument expired");
134
135 Volatility guess = 0.10;
136
137 ImpliedVolHelper f(*this, probability, recoveryRate, termStructure, targetValue);
138 Brent solver;
139 solver.setMaxEvaluations(maxEvaluations);
140 return solver.solve(f, accuracy, guess, minVol, maxVol);
141}
bool isExpired() const override
Definition: cdsoption.cpp:92
+ Here is the call graph for this function:

◆ setupExpired()

void setupExpired ( ) const
overrideprivate

Definition at line 94 of file cdsoption.cpp.

94 {
95 Instrument::setupExpired();
96 riskyAnnuity_ = 0.0;
97}

◆ fetchResults()

void fetchResults ( const PricingEngine::results *  r) const
overrideprivate

Definition at line 113 of file cdsoption.cpp.

113 {
114 Option::fetchResults(r);
115 const CdsOption::results* results = dynamic_cast<const CdsOption::results*>(r);
116 QL_ENSURE(results != 0, "wrong results type");
117 riskyAnnuity_ = results->riskyAnnuity;
118}

Member Data Documentation

◆ swap_

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

Definition at line 99 of file cdsoption.hpp.

◆ knocksOut_

bool knocksOut_
private

Definition at line 100 of file cdsoption.hpp.

◆ strike_

Real strike_
private

Definition at line 101 of file cdsoption.hpp.

◆ strikeType_

StrikeType strikeType_
private

Definition at line 102 of file cdsoption.hpp.

◆ riskyAnnuity_

Real riskyAnnuity_
mutableprivate

Definition at line 104 of file cdsoption.hpp.