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

Abstract Black volatility surface based on moneyness (moneyness defined in subclasses) More...

#include <qle/termstructures/blackvariancesurfacemoneyness.hpp>

+ Inheritance diagram for BlackVarianceSurfaceMoneyness:
+ Collaboration diagram for BlackVarianceSurfaceMoneyness:

Public Member Functions

 BlackVarianceSurfaceMoneyness (const Calendar &cal, const Handle< Quote > &spot, const std::vector< Time > &times, const std::vector< Real > &moneyness, const std::vector< std::vector< Handle< Quote > > > &blackVolMatrix, const DayCounter &dayCounter, bool stickyStrike, bool flatExtrapMoneyness=false)
 
 BlackVarianceSurfaceMoneyness (const Date &referenceDate, const Calendar &cal, const Handle< Quote > &spot, const std::vector< Time > &times, const std::vector< Real > &moneyness, const std::vector< std::vector< Handle< Quote > > > &blackVolMatrix, const DayCounter &dayCounter, bool stickyStrike, bool flatExtrapMoneyness=false)
 Moneyness variance surface with a fixed reference date. More...
 
TermStructure interface
Date maxDate () const override
 
VolatilityTermStructure interface
Real minStrike () const override
 
Real maxStrike () const override
 
Observer interface
void update () override
 
LazyObject interface
void performCalculations () const override
 
Visitability
virtual void accept (AcyclicVisitor &) override
 

Inspectors

bool stickyStrike_
 
Handle< Quote > spot_
 
std::vector< Time > times_
 
std::vector< Real > moneyness_
 
bool flatExtrapMoneyness_
 
std::vector< std::vector< Handle< Quote > > > quotes_
 
Matrix variances_
 
Interpolation2D varianceSurface_
 
std::vector< QuantLib::Real > moneyness () const
 
virtual Real moneyness (Time t, Real strike) const =0
 
void init ()
 
Real blackVarianceMoneyness (Time t, Real moneyness) const
 
virtual Real blackVarianceImpl (Time t, Real strike) const override
 

Detailed Description

Abstract Black volatility surface based on moneyness (moneyness defined in subclasses)

Definition at line 46 of file blackvariancesurfacemoneyness.hpp.

Constructor & Destructor Documentation

◆ BlackVarianceSurfaceMoneyness() [1/2]

BlackVarianceSurfaceMoneyness ( const Calendar &  cal,
const Handle< Quote > &  spot,
const std::vector< Time > &  times,
const std::vector< Real > &  moneyness,
const std::vector< std::vector< Handle< Quote > > > &  blackVolMatrix,
const DayCounter &  dayCounter,
bool  stickyStrike,
bool  flatExtrapMoneyness = false 
)

Moneyness can be defined here as spot moneyness, i.e. K/S or forward moneyness, ie K/F

Definition at line 30 of file blackvariancesurfacemoneyness.cpp.

+ Here is the call graph for this function:

◆ BlackVarianceSurfaceMoneyness() [2/2]

BlackVarianceSurfaceMoneyness ( const Date &  referenceDate,
const Calendar &  cal,
const Handle< Quote > &  spot,
const std::vector< Time > &  times,
const std::vector< Real > &  moneyness,
const std::vector< std::vector< Handle< Quote > > > &  blackVolMatrix,
const DayCounter &  dayCounter,
bool  stickyStrike,
bool  flatExtrapMoneyness = false 
)

Moneyness variance surface with a fixed reference date.

Definition at line 39 of file blackvariancesurfacemoneyness.cpp.

43 : BlackVarianceTermStructure(referenceDate, cal, Following, dayCounter), stickyStrike_(stickyStrike), spot_(spot),
44 times_(times), moneyness_(moneyness), flatExtrapMoneyness_(flatExtrapMoneyness), quotes_(blackVolMatrix) {
45 init();
46}
+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 64 of file blackvariancesurfacemoneyness.hpp.

64{ return Date::maxDate(); }

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 68 of file blackvariancesurfacemoneyness.hpp.

68{ return 0; }

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 69 of file blackvariancesurfacemoneyness.hpp.

69{ return QL_MAX_REAL; }

◆ update()

void update ( )
override

Definition at line 48 of file blackvariancesurfacemoneyness.cpp.

48 {
49 TermStructure::update();
50 LazyObject::update();
51}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 53 of file blackvariancesurfacemoneyness.cpp.

53 {
54 for (Size j = 1; j < variances_.columns(); j++) {
55 for (Size i = 0; i < variances_.rows(); i++) {
56 Real vol = quotes_[i][j - 1]->value();
57 variances_[i][j] = times_[j] * vol * vol;
58 }
59 }
60 varianceSurface_.update();
61}

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 110 of file blackvariancesurfacemoneyness.hpp.

110 {
111 Visitor<BlackVarianceSurfaceMoneyness>* v1 = dynamic_cast<Visitor<BlackVarianceSurfaceMoneyness>*>(&v);
112 if (v1 != 0)
113 v1->visit(*this);
114 else
115 BlackVarianceTermStructure::accept(v);
116}

◆ moneyness() [1/2]

std::vector< QuantLib::Real > moneyness ( ) const

Definition at line 86 of file blackvariancesurfacemoneyness.hpp.

86{ return moneyness_; }
+ Here is the caller graph for this function:

◆ moneyness() [2/2]

virtual Real moneyness ( Time  t,
Real  strike 
) const
protectedpure virtual

◆ init()

void init ( )
private

Definition at line 63 of file blackvariancesurfacemoneyness.cpp.

63 {
64
65 QL_REQUIRE(times_.size() == quotes_.front().size(), "mismatch between times vector and vol matrix columns");
66 QL_REQUIRE(moneyness_.size() == quotes_.size(), "mismatch between moneyness vector and vol matrix rows");
67
68 QL_REQUIRE(times_[0] > 0, "The first time must be greater than 0.0.");
69
70 if (stickyStrike_) {
71 // we don't want to know if the spot has changed - we take a copy here
72 spot_ = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(spot_->value()));
73 } else {
74 registerWith(spot_);
75 }
76
77 // Insert time 0.0 in times_ and initialise variances_ with 0.0.
78 times_.insert(times_.begin(), 0.0);
79 variances_ = Matrix(moneyness_.size(), times_.size(), 0.0);
80
81 // Check times_ and register with quotes
82 for (Size j = 1; j < times_.size(); j++) {
83
84 QL_REQUIRE(times_[j] > times_[j - 1], "Times must be sorted and unique but found that the "
85 << io::ordinal(j) << " time, " << times_[j]
86 << ", is not greater than the " << io::ordinal(j - 1) << " time, "
87 << times_[j - 1] << ".");
88
89 for (Size i = 0; i < moneyness_.size(); i++) {
90 registerWith(quotes_[i][j - 1]);
91 }
92 }
93
95 Bilinear().interpolate(times_.begin(), times_.end(), moneyness_.begin(), moneyness_.end(), variances_);
96
97 notifyObservers();
98}
+ Here is the caller graph for this function:

◆ blackVarianceMoneyness()

Real blackVarianceMoneyness ( Time  t,
Real  moneyness 
) const
private

Definition at line 110 of file blackvariancesurfacemoneyness.cpp.

110 {
111 if (t <= times_.back())
112 return varianceSurface_(t, m, true);
113 else
114 return varianceSurface_(times_.back(), m, true) * t / times_.back();
115}
+ Here is the caller graph for this function:

◆ blackVarianceImpl()

Real blackVarianceImpl ( Time  t,
Real  strike 
) const
overrideprivatevirtual

Definition at line 100 of file blackvariancesurfacemoneyness.cpp.

100 {
101
102 calculate();
103
104 if (t == 0.0)
105 return 0.0;
106
107 return std::max(blackVarianceMoneyness(t, moneyness(t, strike)), 0.0);
108}
Real blackVarianceMoneyness(Time t, Real moneyness) const
+ Here is the call graph for this function:

Member Data Documentation

◆ stickyStrike_

bool stickyStrike_
protected

Definition at line 91 of file blackvariancesurfacemoneyness.hpp.

◆ spot_

Handle<Quote> spot_
protected

Definition at line 92 of file blackvariancesurfacemoneyness.hpp.

◆ times_

std::vector<Time> times_
protected

Definition at line 93 of file blackvariancesurfacemoneyness.hpp.

◆ moneyness_

std::vector<Real> moneyness_
protected

Definition at line 94 of file blackvariancesurfacemoneyness.hpp.

◆ flatExtrapMoneyness_

bool flatExtrapMoneyness_
protected

Definition at line 95 of file blackvariancesurfacemoneyness.hpp.

◆ quotes_

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

Definition at line 103 of file blackvariancesurfacemoneyness.hpp.

◆ variances_

Matrix variances_
mutableprivate

Definition at line 104 of file blackvariancesurfacemoneyness.hpp.

◆ varianceSurface_

Interpolation2D varianceSurface_
mutableprivate

Definition at line 105 of file blackvariancesurfacemoneyness.hpp.