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
SpreadedBlackVolatilityCurve Class Reference

Spreaded Black volatility curve modeled as variance curve. More...

#include <qle/termstructures/spreadedblackvolatilitycurve.hpp>

+ Inheritance diagram for SpreadedBlackVolatilityCurve:
+ Collaboration diagram for SpreadedBlackVolatilityCurve:

Public Member Functions

 SpreadedBlackVolatilityCurve (const Handle< BlackVolTermStructure > &referenceVol, const std::vector< Time > &times, const std::vector< Handle< Quote > > &volSpreads, const bool useAtmReferenceVolsOnly=false)
 
Date maxDate () const override
 
const Date & referenceDate () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
Real minStrike () const override
 
Real maxStrike () const override
 
void update () override
 

Private Member Functions

void performCalculations () const override
 
Real blackVolImpl (Time t, Real) const override
 

Private Attributes

Handle< BlackVolTermStructurereferenceVol_
 
std::vector< Time > times_
 
std::vector< Handle< Quote > > volSpreads_
 
bool useAtmReferenceVolsOnly_
 
std::vector< Real > data_
 
QuantLib::ext::shared_ptr< Interpolation > interpolation_
 

Detailed Description

Spreaded Black volatility curve modeled as variance curve.

Definition at line 35 of file spreadedblackvolatilitycurve.hpp.

Constructor & Destructor Documentation

◆ SpreadedBlackVolatilityCurve()

SpreadedBlackVolatilityCurve ( const Handle< BlackVolTermStructure > &  referenceVol,
const std::vector< Time > &  times,
const std::vector< Handle< Quote > > &  volSpreads,
const bool  useAtmReferenceVolsOnly = false 
)
  • times should be consistent with reference ts day counter
  • if useAtmReferenceVolsOnly, only vols with strike Null<Real>() are read from the referenceVol, otherwise the full reference vol surface (if it is one) is used

Definition at line 25 of file spreadedblackvolatilitycurve.cpp.

29 : BlackVolatilityTermStructure(referenceVol->businessDayConvention(), referenceVol->dayCounter()),
30 referenceVol_(referenceVol), times_(times), volSpreads_(volSpreads),
31 useAtmReferenceVolsOnly_(useAtmReferenceVolsOnly), data_(times.size(), 0.0) {
32 registerWith(referenceVol_);
33 QL_REQUIRE(times_.size() >= 2, "at least two times required");
34 QL_REQUIRE(times_.size() == volSpreads_.size(), "size of time and quote vectors do not match");
35 for (Size i = 0; i < volSpreads_.size(); ++i)
36 registerWith(volSpreads_[i]);
37 interpolation_ = QuantLib::ext::make_shared<FlatExtrapolation>(
38 QuantLib::ext::make_shared<LinearInterpolation>(times_.begin(), times_.end(), data_.begin()));
39 interpolation_->enableExtrapolation();
40}
QuantLib::ext::shared_ptr< Interpolation > interpolation_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 42 of file spreadedblackvolatilitycurve.cpp.

42{ return referenceVol_->maxDate(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 44 of file spreadedblackvolatilitycurve.cpp.

44{ return referenceVol_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 46 of file spreadedblackvolatilitycurve.cpp.

46{ return referenceVol_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 48 of file spreadedblackvolatilitycurve.cpp.

48{ return referenceVol_->settlementDays(); }

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 50 of file spreadedblackvolatilitycurve.cpp.

50{ return referenceVol_->minStrike(); }

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 52 of file spreadedblackvolatilitycurve.cpp.

52{ return referenceVol_->maxStrike(); }

◆ update()

void update ( )
override

Definition at line 54 of file spreadedblackvolatilitycurve.cpp.

54 {
55 LazyObject::update();
56 BlackVolatilityTermStructure::update();
57}

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 59 of file spreadedblackvolatilitycurve.cpp.

59 {
60 for (Size i = 0; i < times_.size(); ++i) {
61 QL_REQUIRE(!volSpreads_[i].empty(), "SpreadedBlackVolatilityCurve: empty quote at index " << (i - 1));
62 data_[i] = volSpreads_[i]->value();
63 }
64 interpolation_->update();
65}

◆ blackVolImpl()

Real blackVolImpl ( Time  t,
Real  k 
) const
overrideprivate

Definition at line 67 of file spreadedblackvolatilitycurve.cpp.

67 {
68 calculate();
69 return referenceVol_->blackVol(t, useAtmReferenceVolsOnly_ ? Null<Real>() : k) + (*interpolation_)(t);
70}

Member Data Documentation

◆ referenceVol_

Handle<BlackVolTermStructure> referenceVol_
private

Definition at line 56 of file spreadedblackvolatilitycurve.hpp.

◆ times_

std::vector<Time> times_
private

Definition at line 57 of file spreadedblackvolatilitycurve.hpp.

◆ volSpreads_

std::vector<Handle<Quote> > volSpreads_
private

Definition at line 58 of file spreadedblackvolatilitycurve.hpp.

◆ useAtmReferenceVolsOnly_

bool useAtmReferenceVolsOnly_
private

Definition at line 59 of file spreadedblackvolatilitycurve.hpp.

◆ data_

std::vector<Real> data_
mutableprivate

Definition at line 60 of file spreadedblackvolatilitycurve.hpp.

◆ interpolation_

QuantLib::ext::shared_ptr<Interpolation> interpolation_
private

Definition at line 61 of file spreadedblackvolatilitycurve.hpp.