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

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

#include <qle/termstructures/blackvariancecurve3.hpp>

+ Inheritance diagram for BlackVarianceCurve3:
+ Collaboration diagram for BlackVarianceCurve3:

Public Member Functions

 BlackVarianceCurve3 (Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc, const std::vector< Time > &times, const std::vector< Handle< Quote > > &blackVolCurve, bool requireMonotoneVariance=true)
 
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

std::vector< Time > times_
 
std::vector< Handle< Quote > > quotes_
 
std::vector< Real > variances_
 
Interpolation varianceCurve_
 
bool requireMonotoneVariance_
 
virtual void accept (AcyclicVisitor &) override
 
virtual Real blackVarianceImpl (Time t, Real) const override
 

Detailed Description

Black volatility curve modeled as variance curve.

This class calculates time-dependent Black volatilities using as input a vector of (ATM) Black volatilities observed in the market.

The calculation is performed interpolating on the variance curve. Linear interpolation is used.

Definition at line 47 of file blackvariancecurve3.hpp.

Constructor & Destructor Documentation

◆ BlackVarianceCurve3()

BlackVarianceCurve3 ( Natural  settlementDays,
const Calendar &  cal,
BusinessDayConvention  bdc,
const DayCounter &  dc,
const std::vector< Time > &  times,
const std::vector< Handle< Quote > > &  blackVolCurve,
bool  requireMonotoneVariance = true 
)

Definition at line 24 of file blackvariancecurve3.cpp.

27 : BlackVarianceTermStructure(settlementDays, cal, bdc, dc), times_(times), quotes_(blackVolCurve),
28 requireMonotoneVariance_(requireMonotoneVariance) {
29
30 QL_REQUIRE(times.size() == blackVolCurve.size(), "mismatch between date vector and black vol vector");
31
32 // cannot have dates[0]==referenceDate, since the
33 // value of the vol at dates[0] would be lost
34 // (variance at referenceDate must be zero)
35 QL_REQUIRE(times[0] > 0, "cannot have times[0] <= 0");
36
37 // Now insert 0 at the start of times_
38 times_.insert(times_.begin(), 0);
39
40 variances_ = std::vector<Real>(times_.size());
41 variances_[0] = 0.0;
42 for (Size j = 1; j < times_.size(); j++) {
43 QL_REQUIRE(times_[j] > times_[j - 1], "times must be sorted unique!");
44 registerWith(quotes_[j - 1]);
45 }
46 varianceCurve_ = Linear().interpolate(times_.begin(), times_.end(), variances_.begin());
47}
std::vector< Handle< Quote > > quotes_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 87 of file blackvariancecurve3.hpp.

87{ return Date::maxDate(); }

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 89 of file blackvariancecurve3.hpp.

89{ return QL_MIN_REAL; }

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 91 of file blackvariancecurve3.hpp.

91{ return QL_MAX_REAL; }

◆ update()

void update ( )
override

Definition at line 49 of file blackvariancecurve3.cpp.

49 {
50 TermStructure::update(); // calls notifyObservers
51 LazyObject::update(); // as does this
52}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 54 of file blackvariancecurve3.cpp.

54 {
55 for (Size j = 1; j <= quotes_.size(); j++) {
56 variances_[j] = times_[j] * quotes_[j - 1]->value() * quotes_[j - 1]->value();
58 QL_REQUIRE(variances_[j] >= variances_[j - 1],
59 "variance must be non-decreasing at j:" << j << " got var[j]:" << variances_[j]
60 << " and var[j-1]:" << variances_[j - 1]);
61 }
62 }
63 varianceCurve_.update();
64}

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 93 of file blackvariancecurve3.hpp.

93 {
94 Visitor<BlackVarianceCurve3>* v1 = dynamic_cast<Visitor<BlackVarianceCurve3>*>(&v);
95 if (v1 != 0)
96 v1->visit(*this);
97 else
98 BlackVarianceTermStructure::accept(v);
99}

◆ blackVarianceImpl()

Real blackVarianceImpl ( Time  t,
Real   
) const
overrideprotectedvirtual

Definition at line 66 of file blackvariancecurve3.cpp.

66 {
67 calculate();
68 if (t <= times_.back()) {
69 return varianceCurve_(t, true);
70 } else {
71 // extrapolate with flat vol
72 return varianceCurve_(times_.back(), true) * t / times_.back();
73 }
74}

Member Data Documentation

◆ times_

std::vector<Time> times_
private

Definition at line 78 of file blackvariancecurve3.hpp.

◆ quotes_

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

Definition at line 79 of file blackvariancecurve3.hpp.

◆ variances_

std::vector<Real> variances_
mutableprivate

Definition at line 80 of file blackvariancecurve3.hpp.

◆ varianceCurve_

Interpolation varianceCurve_
mutableprivate

Definition at line 81 of file blackvariancecurve3.hpp.

◆ requireMonotoneVariance_

bool requireMonotoneVariance_
private

Definition at line 82 of file blackvariancecurve3.hpp.