Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CreditVolCurve Class Referenceabstract

#include <qle/termstructures/creditvolcurve.hpp>

+ Inheritance diagram for CreditVolCurve:
+ Collaboration diagram for CreditVolCurve:

Public Types

enum class  Type { Price , Spread }
 

Public Member Functions

 CreditVolCurve (QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const std::vector< QuantLib::Period > &terms, const std::vector< QuantLib::Handle< CreditCurve > > &termCurves, const Type &type)
 
 CreditVolCurve (const QuantLib::Natural settlementDays, const QuantLib::Calendar &cal, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const std::vector< QuantLib::Period > &terms, const std::vector< QuantLib::Handle< CreditCurve > > &termCurves, const Type &type)
 
 CreditVolCurve (const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const std::vector< QuantLib::Period > &terms, const std::vector< QuantLib::Handle< CreditCurve > > &termCurves, const Type &type)
 
QuantLib::Real volatility (const QuantLib::Date &exerciseDate, const QuantLib::Period &underlyingTerm, const QuantLib::Real strike, const Type &targetType) const
 
virtual QuantLib::Real volatility (const QuantLib::Date &exerciseDate, const QuantLib::Real underlyingLength, const QuantLib::Real strike, const Type &targetType) const =0
 
QuantLib::Real volatility (const QuantLib::Real exerciseTime, const QuantLib::Real underlyingLength, const QuantLib::Real strike, const Type &targetType) const
 
virtual const std::vector< QuantLib::Period > & terms () const
 
virtual const std::vector< QuantLib::Handle< CreditCurve > > & termCurves () const
 
const Typetype () const
 
QuantLib::Real atmStrike (const QuantLib::Date &expiry, const QuantLib::Period &term) const
 
QuantLib::Real atmStrike (const QuantLib::Date &expiry, const QuantLib::Real underlyingLength) const
 
QuantLib::Real minStrike () const override
 
QuantLib::Real maxStrike () const override
 
QuantLib::Date maxDate () const override
 

Protected Member Functions

void init ()
 
void update () override
 
void performCalculations () const override
 
QuantLib::Real moneyness (const QuantLib::Real strike, const QuantLib::Real atmStrike) const
 
QuantLib::Real strike (const QuantLib::Real moneyness, const QuantLib::Real atmStrike) const
 

Protected Attributes

std::vector< QuantLib::Period > terms_
 
std::vector< QuantLib::Handle< CreditCurve > > termCurves_
 
Type type_
 
std::map< std::pair< QuantLib::Date, double >, double > atmStrikeCache_
 

Detailed Description

Definition at line 37 of file creditvolcurve.hpp.

Member Enumeration Documentation

◆ Type

enum class Type
strong
Enumerator
Price 
Spread 

Definition at line 39 of file creditvolcurve.hpp.

Constructor & Destructor Documentation

◆ CreditVolCurve() [1/3]

CreditVolCurve ( QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dc,
const std::vector< QuantLib::Period > &  terms,
const std::vector< QuantLib::Handle< CreditCurve > > &  termCurves,
const Type type 
)

◆ CreditVolCurve() [2/3]

CreditVolCurve ( const QuantLib::Natural  settlementDays,
const QuantLib::Calendar &  cal,
QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dc,
const std::vector< QuantLib::Period > &  terms,
const std::vector< QuantLib::Handle< CreditCurve > > &  termCurves,
const Type type 
)

◆ CreditVolCurve() [3/3]

CreditVolCurve ( const QuantLib::Date &  referenceDate,
const QuantLib::Calendar &  cal,
QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dc,
const std::vector< QuantLib::Period > &  terms,
const std::vector< QuantLib::Handle< CreditCurve > > &  termCurves,
const Type type 
)

Member Function Documentation

◆ volatility() [1/3]

QuantLib::Real volatility ( const QuantLib::Date &  exerciseDate,
const QuantLib::Period &  underlyingTerm,
const QuantLib::Real  strike,
const Type targetType 
) const

◆ volatility() [2/3]

virtual QuantLib::Real volatility ( const QuantLib::Date &  exerciseDate,
const QuantLib::Real  underlyingLength,
const QuantLib::Real  strike,
const Type targetType 
) const
pure virtual

◆ volatility() [3/3]

QuantLib::Real volatility ( const QuantLib::Real  exerciseTime,
const QuantLib::Real  underlyingLength,
const QuantLib::Real  strike,
const Type targetType 
) const

◆ terms()

const std::vector< Period > & terms ( ) const
virtual

Definition at line 92 of file creditvolcurve.cpp.

92{ return terms_; }
std::vector< QuantLib::Period > terms_
+ Here is the caller graph for this function:

◆ termCurves()

const std::vector< Handle< CreditCurve > > & termCurves ( ) const
virtual

Definition at line 94 of file creditvolcurve.cpp.

94{ return termCurves_; }
std::vector< QuantLib::Handle< CreditCurve > > termCurves_
+ Here is the caller graph for this function:

◆ type()

const CreditVolCurve::Type & type ( ) const

Definition at line 96 of file creditvolcurve.cpp.

96{ return type_; }
+ Here is the caller graph for this function:

◆ atmStrike() [1/2]

QuantLib::Real atmStrike ( const QuantLib::Date &  expiry,
const QuantLib::Period &  term 
) const
+ Here is the caller graph for this function:

◆ atmStrike() [2/2]

QuantLib::Real atmStrike ( const QuantLib::Date &  expiry,
const QuantLib::Real  underlyingLength 
) const

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 100 of file creditvolcurve.cpp.

100{ return -QL_MAX_REAL; }

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 102 of file creditvolcurve.cpp.

102{ return QL_MAX_REAL; }

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 98 of file creditvolcurve.cpp.

98{ return Date::maxDate(); }

◆ init()

void init ( )
protected

Definition at line 51 of file creditvolcurve.cpp.

51 {
52 QL_REQUIRE(terms_.size() == termCurves_.size(), "CreditVolCurve: terms size (" << terms_.size()
53 << ") must match termCurves size ("
54 << termCurves_.size());
55 // sort terms and curves
56
57 std::vector<Size> p(terms_.size());
58 std::iota(p.begin(), p.end(), 0);
59 std::sort(p.begin(), p.end(), [this](Size i, Size j) { return this->terms_[i] < this->terms_[j]; });
60
61 std::vector<Period> sortedTerms(terms_.size());
62 std::vector<Handle<CreditCurve>> sortedCurves(terms_.size());
63 std::transform(p.begin(), p.end(), sortedTerms.begin(), [this](Size i) { return this->terms_[i]; });
64 std::transform(p.begin(), p.end(), sortedCurves.begin(), [this](Size i) { return this->termCurves_[i]; });
65
66 terms_ = sortedTerms;
67 termCurves_ = sortedCurves;
68
69 // register with curves
70
71 for (const auto& c : termCurves_)
72 registerWith(c);
73}

◆ update()

void update ( )
overrideprotected

Definition at line 75 of file creditvolcurve.hpp.

75{ LazyObject::update(); }

◆ performCalculations()

void performCalculations ( ) const
overrideprotected

Definition at line 261 of file creditvolcurve.cpp.

261{ atmStrikeCache_.clear(); }
std::map< std::pair< QuantLib::Date, double >, double > atmStrikeCache_
+ Here is the caller graph for this function:

◆ moneyness()

Real moneyness ( const QuantLib::Real  strike,
const QuantLib::Real  atmStrike 
) const
protected

Definition at line 104 of file creditvolcurve.cpp.

104 {
105 if (strike == Null<Real>())
106 return 0.0;
107 if (type() == Type::Spread) {
108 return strike - atmStrike;
109 } else if (type() == Type::Price) {
110 return std::log(strike / atmStrike);
111 } else {
112 QL_FAIL("InterpolatingCreditVolCurve::moneyness(): internal error, type not handled");
113 }
114}
QuantLib::Real atmStrike(const QuantLib::Date &expiry, const QuantLib::Period &term) const
QuantLib::Real strike(const QuantLib::Real moneyness, const QuantLib::Real atmStrike) const
const Type & type() const
+ Here is the caller graph for this function:

◆ strike()

Real strike ( const QuantLib::Real  moneyness,
const QuantLib::Real  atmStrike 
) const
protected

Definition at line 116 of file creditvolcurve.cpp.

116 {
117 if (type() == Type::Spread) {
118 return atmStrike + moneyness;
119 } else if (type() == Type::Price) {
120 return atmStrike * std::exp(moneyness);
121 } else {
122 QL_FAIL("InterpolatingCreditVolCurve::strike(): internal error, type not handled");
123 }
124}
QuantLib::Real moneyness(const QuantLib::Real strike, const QuantLib::Real atmStrike) const
+ Here is the caller graph for this function:

Member Data Documentation

◆ terms_

std::vector<QuantLib::Period> terms_
protected

Definition at line 80 of file creditvolcurve.hpp.

◆ termCurves_

std::vector<QuantLib::Handle<CreditCurve> > termCurves_
protected

Definition at line 81 of file creditvolcurve.hpp.

◆ type_

Type type_
protected

Definition at line 82 of file creditvolcurve.hpp.

◆ atmStrikeCache_

std::map<std::pair<QuantLib::Date, double>, double> atmStrikeCache_
mutableprotected

Definition at line 84 of file creditvolcurve.hpp.