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

#include <qle/termstructures/blackvolsurfacedelta.hpp>

+ Inheritance diagram for InterpolatedSmileSection:
+ Collaboration diagram for InterpolatedSmileSection:

Public Types

enum class  InterpolationMethod { Linear , NaturalCubic , FinancialCubic , CubicSpline }
 Supported interpolation methods. More...
 

Public Member Functions

 InterpolatedSmileSection (Real spot, Real rd, Real rf, Time t, const std::vector< Real > &strikes, const std::vector< Volatility > &vols, InterpolationMethod method, bool flatExtrapolation=false)
 ctor More...
 
Volatility volatility (Real strike) const override
 
- Public Member Functions inherited from FxSmileSection
 FxSmileSection ()
 
 FxSmileSection (Real spot, Real rd, Real rf, Time t)
 
virtual ~FxSmileSection ()
 
virtual Volatility volatility (Real strike) const =0
 
DiscountFactor domesticDiscount () const
 
DiscountFactor foreignDiscount () const
 

Inspectors

Interpolation interpolator_
 
std::vector< Real > strikes_
 
std::vector< Volatility > vols_
 
bool flatExtrapolation_
 
const std::vector< Real > & strikes () const
 
const std::vector< Volatility > & volatilities () const
 

Additional Inherited Members

- Protected Attributes inherited from FxSmileSection
Real spot_
 
Real rd_
 
Real rf_
 
Time t_
 

Detailed Description

Definition at line 41 of file blackvolsurfacedelta.hpp.

Member Enumeration Documentation

◆ InterpolationMethod

enum class InterpolationMethod
strong

Constructor & Destructor Documentation

◆ InterpolatedSmileSection()

InterpolatedSmileSection ( Real  spot,
Real  rd,
Real  rf,
Time  t,
const std::vector< Real > &  strikes,
const std::vector< Volatility > &  vols,
InterpolationMethod  method,
bool  flatExtrapolation = false 
)

ctor

Definition at line 31 of file blackvolsurfacedelta.cpp.

35 : FxSmileSection(spot, rd, rf, t), strikes_(strikes), vols_(vols), flatExtrapolation_(flatExtrapolation) {
36
37 if (method == InterpolationMethod::Linear)
38 interpolator_ = Linear().interpolate(strikes_.begin(), strikes_.end(), vols_.begin());
39 else if (method == InterpolationMethod::NaturalCubic)
41 Cubic(CubicInterpolation::Kruger, true).interpolate(strikes_.begin(), strikes_.end(), vols_.begin());
42 else if (method == InterpolationMethod::FinancialCubic)
43 interpolator_ = Cubic(CubicInterpolation::Kruger, true, CubicInterpolation::SecondDerivative, 0.0,
44 CubicInterpolation::FirstDerivative)
45 .interpolate(strikes_.begin(), strikes_.end(), vols_.begin());
46 else if (method == InterpolationMethod::CubicSpline)
47 interpolator_ = CubicNaturalSpline(strikes_.begin(), strikes_.end(), vols_.begin());
48 else {
49 QL_FAIL("Invalid method " << (int)method);
50 }
51}
const std::vector< Real > & strikes() const

Member Function Documentation

◆ volatility()

Volatility volatility ( Real  strike) const
overridevirtual

Implements FxSmileSection.

Definition at line 53 of file blackvolsurfacedelta.cpp.

53 {
55 if (strike < strikes_.front())
56 return vols_.front();
57 else if (strike > strikes_.back())
58 return vols_.back();
59 }
60 // and then call the interpolator with extrapolation on
61 return interpolator_(strike, true);
62}

◆ strikes()

const std::vector< Real > & strikes ( ) const

Definition at line 55 of file blackvolsurfacedelta.hpp.

55{ return strikes_; }

◆ volatilities()

const std::vector< Volatility > & volatilities ( ) const

Definition at line 56 of file blackvolsurfacedelta.hpp.

56{ return vols_; }

Member Data Documentation

◆ interpolator_

Interpolation interpolator_
private

Definition at line 60 of file blackvolsurfacedelta.hpp.

◆ strikes_

std::vector<Real> strikes_
private

Definition at line 61 of file blackvolsurfacedelta.hpp.

◆ vols_

std::vector<Volatility> vols_
private

Definition at line 62 of file blackvolsurfacedelta.hpp.

◆ flatExtrapolation_

bool flatExtrapolation_
private

Definition at line 63 of file blackvolsurfacedelta.hpp.