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

Index CDS option instrument. More...

#include <qle/instruments/indexcdsoption.hpp>

+ Inheritance diagram for IndexCdsOption:
+ Collaboration diagram for IndexCdsOption:

Classes

class  arguments
 Arguments for index CDS option calculation More...
 
class  engine
 Base class for index CDS option engines. More...
 
class  results
 Results from index CDS option calculation More...
 

Public Member Functions

 IndexCdsOption (const QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > &swap, const QuantLib::ext::shared_ptr< QuantLib::Exercise > &exercise, QuantLib::Real strike, CdsOption::StrikeType strikeType_=CdsOption::Spread, Settlement::Type settlementType=Settlement::Cash, QuantLib::Real tradeDateNtl=QuantLib::Null< QuantLib::Real >(), QuantLib::Real realisedFep=QuantLib::Null< QuantLib::Real >(), const QuantLib::Period &indexTerm=5 *Years)
 
Inspectors
const QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > & underlyingSwap () const
 

Calculations

QuantLib::ext::shared_ptr< IndexCreditDefaultSwapswap_
 
QuantLib::Real strike_
 
CdsOption::StrikeType strikeType_
 
Settlement::Type settlementType_
 
QuantLib::Real tradeDateNtl_
 
QuantLib::Real realisedFep_
 
QuantLib::Period indexTerm_
 
QuantLib::Real riskyAnnuity_
 
QuantLib::Rate atmRate () const
 
QuantLib::Real riskyAnnuity () const
 
QuantLib::Volatility impliedVolatility (QuantLib::Real price, const QuantLib::Handle< QuantLib::YieldTermStructure > &termStructureSwapCurrency, const QuantLib::Handle< QuantLib::YieldTermStructure > &termStructureTradeCollateral, const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > &, QuantLib::Real recoveryRate, QuantLib::Real accuracy=1.e-4, QuantLib::Size maxEvaluations=100, QuantLib::Volatility minVol=1.0e-7, QuantLib::Volatility maxVol=4.0) const
 

Instrument interface

bool isExpired () const override
 
void setupArguments (QuantLib::PricingEngine::arguments *args) const override
 
void setupExpired () const override
 
void fetchResults (const QuantLib::PricingEngine::results *results) const override
 

Detailed Description

Index CDS option instrument.

Definition at line 35 of file indexcdsoption.hpp.

Constructor & Destructor Documentation

◆ IndexCdsOption()

IndexCdsOption ( const QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > &  swap,
const QuantLib::ext::shared_ptr< QuantLib::Exercise > &  exercise,
QuantLib::Real  strike,
CdsOption::StrikeType  strikeType_ = CdsOption::Spread,
Settlement::Type  settlementType = Settlement::Cash,
QuantLib::Real  tradeDateNtl = QuantLib::Null<QuantLib::Real>(),
QuantLib::Real  realisedFep = QuantLib::Null<QuantLib::Real>(),
const QuantLib::Period &  indexTerm = 5 * Years 
)

Definition at line 68 of file indexcdsoption.cpp.

72 : Option(QuantLib::ext::make_shared<NullPayoff>(), exercise), swap_(swap), strike_(strike), strikeType_(strikeType),
73 settlementType_(settlementType), tradeDateNtl_(tradeDateNtl), realisedFep_(realisedFep),
74 indexTerm_(indexTerm), riskyAnnuity_(0.0) {
75 registerWith(swap_);
76}
CdsOption::StrikeType strikeType_
QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > swap_
QuantLib::Real riskyAnnuity_
Settlement::Type settlementType_
QuantLib::Real tradeDateNtl_
QuantLib::Period indexTerm_

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 78 of file indexcdsoption.cpp.

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

◆ setupArguments()

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

Definition at line 85 of file indexcdsoption.cpp.

85 {
86 swap_->setupArguments(args);
87 Option::setupArguments(args);
88
89 IndexCdsOption::arguments* arguments = dynamic_cast<IndexCdsOption::arguments*>(args);
90
91 QL_REQUIRE(arguments != 0, "wrong argument type");
92
93 arguments->swap = swap_;
94 arguments->strike = strike_;
95 arguments->strikeType = strikeType_;
96 arguments->settlementType = settlementType_;
97 arguments->tradeDateNtl = tradeDateNtl_;
98 arguments->realisedFep = realisedFep_;
99 arguments->indexTerm = indexTerm_;
100}

◆ underlyingSwap()

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

Definition at line 57 of file indexcdsoption.hpp.

57{ return swap_; }

◆ atmRate()

Rate atmRate ( ) const

Definition at line 109 of file indexcdsoption.cpp.

109{ return swap_->fairSpreadClean(); }

◆ riskyAnnuity()

Real riskyAnnuity ( ) const

Definition at line 111 of file indexcdsoption.cpp.

111 {
112 calculate();
113 QL_REQUIRE(riskyAnnuity_ != Null<Real>(), "risky annuity not provided");
114 return riskyAnnuity_;
115}
+ Here is the caller graph for this function:

◆ impliedVolatility()

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

Definition at line 117 of file indexcdsoption.cpp.

122 {
123 calculate();
124 QL_REQUIRE(!isExpired(), "instrument expired");
125
126 Volatility guess = 0.10;
127
128 ImpliedVolHelper f(*this, probability, recoveryRate, termStructureSwapCurrency, termStructureTradeCollateral,
129 targetValue);
130 Brent solver;
131 solver.setMaxEvaluations(maxEvaluations);
132 return solver.solve(f, accuracy, guess, minVol, maxVol);
133}
bool isExpired() const override
+ Here is the call graph for this function:

◆ setupExpired()

void setupExpired ( ) const
overrideprivate

Definition at line 80 of file indexcdsoption.cpp.

80 {
81 Instrument::setupExpired();
82 riskyAnnuity_ = 0.0;
83}

◆ fetchResults()

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

Definition at line 102 of file indexcdsoption.cpp.

102 {
103 Option::fetchResults(r);
104 const IndexCdsOption::results* results = dynamic_cast<const IndexCdsOption::results*>(r);
105 QL_ENSURE(results != 0, "wrong results type");
106 riskyAnnuity_ = results->riskyAnnuity;
107}

Member Data Documentation

◆ swap_

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

Definition at line 74 of file indexcdsoption.hpp.

◆ strike_

QuantLib::Real strike_
private

Definition at line 75 of file indexcdsoption.hpp.

◆ strikeType_

CdsOption::StrikeType strikeType_
private

Definition at line 76 of file indexcdsoption.hpp.

◆ settlementType_

Settlement::Type settlementType_
private

Definition at line 77 of file indexcdsoption.hpp.

◆ tradeDateNtl_

QuantLib::Real tradeDateNtl_
private

Definition at line 78 of file indexcdsoption.hpp.

◆ realisedFep_

QuantLib::Real realisedFep_
private

Definition at line 79 of file indexcdsoption.hpp.

◆ indexTerm_

QuantLib::Period indexTerm_
private

Definition at line 80 of file indexcdsoption.hpp.

◆ riskyAnnuity_

QuantLib::Real riskyAnnuity_
mutableprivate

Definition at line 82 of file indexcdsoption.hpp.