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

Adapter class for turning a DatedStrippedOptionletBase object into an OptionletVolatilityStructure. More...

#include <qle/termstructures/datedstrippedoptionletadapter.hpp>

+ Inheritance diagram for DatedStrippedOptionletAdapter:
+ Collaboration diagram for DatedStrippedOptionletAdapter:

Public Member Functions

 DatedStrippedOptionletAdapter (const QuantLib::ext::shared_ptr< DatedStrippedOptionletBase > &s, const bool flatExtrapolation)
 
TermStructure interface
Date maxDate () const override
 
VolatilityTermStructure interface
Rate minStrike () const override
 
Rate maxStrike () const override
 
LazyObject interface
void update () override
 
void performCalculations () const override
 
VolatilityType volatilityType () const override
 
Real displacement () const override
 

OptionletVolatilityStructure interface

const QuantLib::ext::shared_ptr< DatedStrippedOptionletBaseoptionletStripper_
 
Size nInterpolations_
 
vector< QuantLib::ext::shared_ptr< Interpolation > > strikeInterpolations_
 
bool flatExtrapolation_
 
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl (Time optionTime) const override
 
Volatility volatilityImpl (Time length, Rate strike) const override
 

Detailed Description

Adapter class for turning a DatedStrippedOptionletBase object into an OptionletVolatilityStructure.

Takes a DatedStrippedOptionletBase and converts it into an OptionletVolatilityStructure with a fixed reference date

    \ingroup termstructures

Definition at line 40 of file datedstrippedoptionletadapter.hpp.

Constructor & Destructor Documentation

◆ DatedStrippedOptionletAdapter()

DatedStrippedOptionletAdapter ( const QuantLib::ext::shared_ptr< DatedStrippedOptionletBase > &  s,
const bool  flatExtrapolation 
)

Definition at line 33 of file datedstrippedoptionletadapter.cpp.

35 : OptionletVolatilityStructure(s->referenceDate(), s->calendar(), s->businessDayConvention(), s->dayCounter()),
37 flatExtrapolation_(flatExtrapolation) {
38 registerWith(optionletStripper_);
39}
const QuantLib::ext::shared_ptr< DatedStrippedOptionletBase > optionletStripper_
vector< QuantLib::ext::shared_ptr< Interpolation > > strikeInterpolations_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 111 of file datedstrippedoptionletadapter.cpp.

111{ return optionletStripper_->optionletFixingDates().back(); }

◆ minStrike()

Rate minStrike ( ) const
override

Definition at line 95 of file datedstrippedoptionletadapter.cpp.

95 {
96 Rate minStrike = optionletStripper_->optionletStrikes(0).front();
97 for (Size i = 1; i < nInterpolations_; ++i) {
98 minStrike = min(optionletStripper_->optionletStrikes(i).front(), minStrike);
99 }
100 return minStrike;
101}
CompiledFormula min(CompiledFormula x, const CompiledFormula &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maxStrike()

Rate maxStrike ( ) const
override

Definition at line 103 of file datedstrippedoptionletadapter.cpp.

103 {
104 Rate maxStrike = optionletStripper_->optionletStrikes(0).back();
105 for (Size i = 1; i < nInterpolations_; ++i) {
106 maxStrike = max(optionletStripper_->optionletStrikes(i).back(), maxStrike);
107 }
108 return maxStrike;
109}
CompiledFormula max(CompiledFormula x, const CompiledFormula &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

void update ( )
override

Definition at line 76 of file datedstrippedoptionletadapter.hpp.

76 {
77 TermStructure::update();
78 LazyObject::update();
79}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 82 of file datedstrippedoptionletadapter.cpp.

82 {
83 for (Size i = 0; i < nInterpolations_; ++i) {
84 const vector<Rate>& optionletStrikes = optionletStripper_->optionletStrikes(i);
85 const vector<Volatility>& optionletVolatilities = optionletStripper_->optionletVolatilities(i);
86 QuantLib::ext::shared_ptr<Interpolation> tmp = QuantLib::ext::make_shared<LinearInterpolation>(
87 optionletStrikes.begin(), optionletStrikes.end(), optionletVolatilities.begin());
89 strikeInterpolations_[i] = QuantLib::ext::make_shared<FlatExtrapolation>(tmp);
90 else
91 strikeInterpolations_[i] = tmp;
92 }
93}

◆ volatilityType()

VolatilityType volatilityType ( ) const
override

Definition at line 113 of file datedstrippedoptionletadapter.cpp.

113{ return optionletStripper_->volatilityType(); }
+ Here is the caller graph for this function:

◆ displacement()

Real displacement ( ) const
override

Definition at line 115 of file datedstrippedoptionletadapter.cpp.

115{ return optionletStripper_->displacement(); }
+ Here is the caller graph for this function:

◆ smileSectionImpl()

QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl ( Time  optionTime) const
overrideprotected

Definition at line 41 of file datedstrippedoptionletadapter.cpp.

41 {
42
43 // Arbitrarily choose the first row of strikes for the smile section independent variable
44 // Generally a reasonable choice since:
45 // 1) OptionletStripper1: all strike rows are the same
46 // 2) OptionletStripper2: optionletStrikes(i) is a decreasing sequence
47 // Still possibility of arbitrary externally provided strike rows where (0) does not include all
48 vector<Rate> optionletStrikes = optionletStripper_->optionletStrikes(0);
49 vector<Real> stdDevs(optionletStrikes.size());
50 Real tEff = flatExtrapolation_ ? std::min(t, optionletStripper_->optionletFixingTimes().back()) : t;
51 for (Size i = 0; i < optionletStrikes.size(); ++i) {
52 stdDevs[i] = volatilityImpl(tEff, optionletStrikes[i]) * sqrt(tEff);
53 }
54
55 // Use a linear interpolated smile section.
56 // TODO: possibly make this configurable?
58 return QuantLib::ext::make_shared<InterpolatedSmileSection<LinearFlat> >(t, optionletStrikes, stdDevs, Null<Real>(),
59 LinearFlat(), Actual365Fixed(),
61 else
62 return QuantLib::ext::make_shared<InterpolatedSmileSection<Linear> >(
63 t, optionletStrikes, stdDevs, Null<Real>(), Linear(), Actual365Fixed(), volatilityType(), displacement());
64}
Volatility volatilityImpl(Time length, Rate strike) const override
RandomVariable sqrt(RandomVariable x)
+ Here is the call graph for this function:

◆ volatilityImpl()

Volatility volatilityImpl ( Time  length,
Rate  strike 
) const
overrideprotected

Definition at line 66 of file datedstrippedoptionletadapter.cpp.

66 {
67 calculate();
68
69 vector<Volatility> vol(nInterpolations_);
70 for (Size i = 0; i < nInterpolations_; ++i)
71 vol[i] = strikeInterpolations_[i]->operator()(strike, true);
72
73 const vector<Time>& optionletTimes = optionletStripper_->optionletFixingTimes();
74 QuantLib::ext::shared_ptr<LinearInterpolation> timeInterpolator =
75 QuantLib::ext::make_shared<LinearInterpolation>(optionletTimes.begin(), optionletTimes.end(), vol.begin());
76 Real lengthEff = flatExtrapolation_ ? std::max(std::min(length, optionletStripper_->optionletFixingTimes().back()),
77 optionletStripper_->optionletFixingTimes().front())
78 : length;
79 return timeInterpolator->operator()(lengthEff, true);
80}
+ Here is the caller graph for this function:

Member Data Documentation

◆ optionletStripper_

const QuantLib::ext::shared_ptr<DatedStrippedOptionletBase> optionletStripper_
private

Definition at line 70 of file datedstrippedoptionletadapter.hpp.

◆ nInterpolations_

Size nInterpolations_
private

Definition at line 71 of file datedstrippedoptionletadapter.hpp.

◆ strikeInterpolations_

vector<QuantLib::ext::shared_ptr<Interpolation> > strikeInterpolations_
mutableprivate

Definition at line 72 of file datedstrippedoptionletadapter.hpp.

◆ flatExtrapolation_

bool flatExtrapolation_
private

Definition at line 73 of file datedstrippedoptionletadapter.hpp.