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

#include <qle/termstructures/creditvolcurve.hpp>

+ Inheritance diagram for SpreadedCreditVolCurve:
+ Collaboration diagram for SpreadedCreditVolCurve:

Public Member Functions

 SpreadedCreditVolCurve (const QuantLib::Handle< CreditVolCurve > baseCurve, const std::vector< QuantLib::Date > expiries, const std::vector< QuantLib::Handle< QuantLib::Quote > > spreads, const bool stickyMoneyness, const std::vector< QuantLib::Period > &terms={}, const std::vector< QuantLib::Handle< CreditCurve > > &termCurves={})
 
QuantLib::Real volatility (const QuantLib::Date &exerciseDate, const QuantLib::Real underlyingLength, const QuantLib::Real strike, const Type &targetType) const override
 
const QuantLib::Date & referenceDate () const override
 
- Public Member Functions inherited from CreditVolCurve
 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
 

Private Member Functions

void performCalculations () const override
 

Private Attributes

QuantLib::Handle< CreditVolCurvebaseCurve_
 
std::vector< QuantLib::Date > expiries_
 
std::vector< QuantLib::Handle< QuantLib::Quote > > spreads_
 
const bool stickyMoneyness_
 
std::vector< QuantLib::Real > times_
 
std::vector< QuantLib::Real > spreadValues_
 
QuantLib::ext::shared_ptr< QuantLib::Interpolation > interpolatedSpreads_
 

Additional Inherited Members

- Public Types inherited from CreditVolCurve
enum class  Type { Price , Spread }
 
- Protected Member Functions inherited from CreditVolCurve
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 inherited from CreditVolCurve
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 142 of file creditvolcurve.hpp.

Constructor & Destructor Documentation

◆ SpreadedCreditVolCurve()

SpreadedCreditVolCurve ( const QuantLib::Handle< CreditVolCurve baseCurve,
const std::vector< QuantLib::Date >  expiries,
const std::vector< QuantLib::Handle< QuantLib::Quote > >  spreads,
const bool  stickyMoneyness,
const std::vector< QuantLib::Period > &  terms = {},
const std::vector< QuantLib::Handle< CreditCurve > > &  termCurves = {} 
)

Definition at line 566 of file creditvolcurve.cpp.

570 : CreditVolCurve(baseCurve->businessDayConvention(), baseCurve->dayCounter(), terms, termCurves, baseCurve->type()),
571 baseCurve_(baseCurve), expiries_(expiries), spreads_(spreads), stickyMoneyness_(stickyMoneyness) {
572 for (auto const& s : spreads)
573 registerWith(s);
574}
CreditVolCurve(QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const std::vector< QuantLib::Period > &terms, const std::vector< QuantLib::Handle< CreditCurve > > &termCurves, const Type &type)
virtual const std::vector< QuantLib::Handle< CreditCurve > > & termCurves() const
virtual const std::vector< QuantLib::Period > & terms() const
std::vector< QuantLib::Handle< QuantLib::Quote > > spreads_
std::vector< QuantLib::Date > expiries_
QuantLib::Handle< CreditVolCurve > baseCurve_

Member Function Documentation

◆ volatility()

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

Implements CreditVolCurve.

Definition at line 593 of file creditvolcurve.cpp.

594 {
595 calculate();
596 Real effectiveStrike = strike;
597 if (stickyMoneyness_ && !baseCurve_->terms().empty() && !this->terms().empty()) {
598 effectiveStrike = this->strike(this->moneyness(strike, this->atmStrike(exerciseDate, underlyingLength)),
599 baseCurve_->atmStrike(exerciseDate, underlyingLength));
600 }
601 Real base = baseCurve_->volatility(exerciseDate, underlyingLength, effectiveStrike, targetType);
602 Real spread = interpolatedSpreads_->operator()(timeFromReference(exerciseDate));
603 return base + spread;
604}
QuantLib::Real moneyness(const QuantLib::Real strike, const QuantLib::Real atmStrike) const
QuantLib::Real atmStrike(const QuantLib::Date &expiry, const QuantLib::Period &term) const
QuantLib::Real strike(const QuantLib::Real moneyness, const QuantLib::Real atmStrike) const
QuantLib::ext::shared_ptr< QuantLib::Interpolation > interpolatedSpreads_
+ Here is the call graph for this function:

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 576 of file creditvolcurve.cpp.

576{ return baseCurve_->referenceDate(); }

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 578 of file creditvolcurve.cpp.

578 {
580 times_.clear();
581 spreadValues_.clear();
582 for (auto const& d : expiries_) {
583 times_.push_back(timeFromReference(d));
584 }
585 for (auto const& s : spreads_) {
586 spreadValues_.push_back(s->value());
587 }
588 interpolatedSpreads_ = QuantLib::ext::make_shared<FlatExtrapolation>(
589 QuantLib::ext::make_shared<LinearInterpolation>(times_.begin(), times_.end(), spreadValues_.begin()));
590 interpolatedSpreads_->enableExtrapolation();
591}
void performCalculations() const override
std::vector< QuantLib::Real > spreadValues_
std::vector< QuantLib::Real > times_
+ Here is the call graph for this function:

Member Data Documentation

◆ baseCurve_

QuantLib::Handle<CreditVolCurve> baseCurve_
private

Definition at line 159 of file creditvolcurve.hpp.

◆ expiries_

std::vector<QuantLib::Date> expiries_
private

Definition at line 160 of file creditvolcurve.hpp.

◆ spreads_

std::vector<QuantLib::Handle<QuantLib::Quote> > spreads_
private

Definition at line 161 of file creditvolcurve.hpp.

◆ stickyMoneyness_

const bool stickyMoneyness_
private

Definition at line 162 of file creditvolcurve.hpp.

◆ times_

std::vector<QuantLib::Real> times_
mutableprivate

Definition at line 164 of file creditvolcurve.hpp.

◆ spreadValues_

std::vector<QuantLib::Real> spreadValues_
mutableprivate

Definition at line 165 of file creditvolcurve.hpp.

◆ interpolatedSpreads_

QuantLib::ext::shared_ptr<QuantLib::Interpolation> interpolatedSpreads_
mutableprivate

Definition at line 166 of file creditvolcurve.hpp.