QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AndreasenHugeVolatilityInterpl Class Reference

Calibration of a local volatility surface to a sparse grid of options. More...

#include <andreasenhugevolatilityinterpl.hpp>

+ Inheritance diagram for AndreasenHugeVolatilityInterpl:
+ Collaboration diagram for AndreasenHugeVolatilityInterpl:

Classes

struct  SingleStepCalibrationResult
 

Public Types

enum  InterpolationType { PiecewiseConstant , Linear , CubicSpline }
 
enum  CalibrationType { Call = Option::Call , Put = Option::Put , CallPut }
 
typedef std::vector< std::pair< ext::shared_ptr< VanillaOption >, ext::shared_ptr< Quote > > > CalibrationSet
 
- Public Types inherited from Observer
typedef set_type::iterator iterator
 

Public Member Functions

 AndreasenHugeVolatilityInterpl (const CalibrationSet &calibrationSet, Handle< Quote > spot, Handle< YieldTermStructure > rTS, Handle< YieldTermStructure > qTS, InterpolationType interpolationType=CubicSpline, CalibrationType calibrationType=Call, Size nGridPoints=500, Real minStrike=Null< Real >(), Real maxStrike=Null< Real >(), ext::shared_ptr< OptimizationMethod > optimizationMethod=ext::shared_ptr< OptimizationMethod >(new LevenbergMarquardt), const EndCriteria &endCriteria=EndCriteria(500, 100, 1e-12, 1e-10, 1e-10))
 
Date maxDate () const
 
Real minStrike () const
 
Real maxStrike () const
 
Real fwd (Time t) const
 
const Handle< YieldTermStructure > & riskFreeRate () const
 
ext::tuple< Real, Real, RealcalibrationError () const
 
Real optionPrice (Time t, Real strike, Option::Type optionType) const
 
Volatility localVol (Time t, Real strike) const
 
- Public Member Functions inherited from LazyObject
 LazyObject ()
 
 ~LazyObject () override=default
 
void update () override
 
bool isCalculated () const
 
void forwardFirstNotificationOnly ()
 
void alwaysForwardNotifications ()
 
void recalculate ()
 
void freeze ()
 
void unfreeze ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 

Protected Member Functions

void performCalculations () const override
 
- Protected Member Functions inherited from LazyObject
virtual void calculate () const
 

Private Types

typedef std::map< Time, ext::tuple< Real, ext::shared_ptr< Array >, ext::shared_ptr< Interpolation > > > TimeValueCacheType
 

Private Member Functions

ext::shared_ptr< AndreasenHugeCostFunction > buildCostFunction (Size iExpiry, Option::Type optionType, const Array &previousNPVs) const
 
Size getExerciseTimeIdx (Time t) const
 
Real getCacheValue (Real strike, const TimeValueCacheType::const_iterator &f) const
 
Array getPriceSlice (Time t, Option::Type optionType) const
 
Array getLocalVolSlice (Time t, Option::Type optionType) const
 

Private Attributes

CalibrationSet calibrationSet_
 
const Handle< Quotespot_
 
const Handle< YieldTermStructurerTS_
 
const Handle< YieldTermStructureqTS_
 
const InterpolationType interpolationType_
 
const CalibrationType calibrationType_
 
const Size nGridPoints_
 
const Real minStrike_
 
const Real maxStrike_
 
const ext::shared_ptr< OptimizationMethodoptimizationMethod_
 
const EndCriteria endCriteria_
 
std::vector< Realstrikes_
 
std::vector< Dateexpiries_
 
std::vector< TimeexpiryTimes_
 
std::vector< TimedT_
 
std::vector< std::vector< Size > > calibrationMatrix_
 
Real avgError_
 
Real minError_
 
Real maxError_
 
ext::shared_ptr< FdmMesherCompositemesher_
 
Array gridPoints_
 
Array gridInFwd_
 
std::vector< SingleStepCalibrationResultcalibrationResults_
 
TimeValueCacheType localVolCache_
 
TimeValueCacheType priceCache_
 

Additional Inherited Members

- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 

Detailed Description

Calibration of a local volatility surface to a sparse grid of options.

References:

Andreasen J., Huge B., 2010. Volatility Interpolation https://ssrn.com/abstract=1694972

Definition at line 54 of file andreasenhugevolatilityinterpl.hpp.

Member Typedef Documentation

◆ CalibrationSet

typedef std::vector<std::pair< ext::shared_ptr<VanillaOption>, ext::shared_ptr<Quote> > > CalibrationSet

Definition at line 63 of file andreasenhugevolatilityinterpl.hpp.

◆ TimeValueCacheType

typedef std::map<Time, ext::tuple< Real, ext::shared_ptr<Array>, ext::shared_ptr<Interpolation> > > TimeValueCacheType
private

Definition at line 103 of file andreasenhugevolatilityinterpl.hpp.

Member Enumeration Documentation

◆ InterpolationType

Enumerator
PiecewiseConstant 
Linear 
CubicSpline 

Definition at line 57 of file andreasenhugevolatilityinterpl.hpp.

◆ CalibrationType

Enumerator
Call 
Put 
CallPut 

Definition at line 58 of file andreasenhugevolatilityinterpl.hpp.

Constructor & Destructor Documentation

◆ AndreasenHugeVolatilityInterpl()

AndreasenHugeVolatilityInterpl ( const CalibrationSet calibrationSet,
Handle< Quote spot,
Handle< YieldTermStructure rTS,
Handle< YieldTermStructure qTS,
InterpolationType  interpolationType = CubicSpline,
CalibrationType  calibrationType = Call,
Size  nGridPoints = 500,
Real  minStrike = Null<Real>(),
Real  maxStrike = Null<Real>(),
ext::shared_ptr< OptimizationMethod optimizationMethod = ext::shared_ptr<OptimizationMethod>(new LevenbergMarquardt),
const EndCriteria endCriteria = EndCriteria(500, 100, 1e-12, 1e-10, 1e-10) 
)

Definition at line 210 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const

Definition at line 447 of file andreasenhugevolatilityinterpl.cpp.

◆ minStrike()

Real minStrike ( ) const

Definition at line 451 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the caller graph for this function:

◆ maxStrike()

Real maxStrike ( ) const

Definition at line 456 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the caller graph for this function:

◆ fwd()

Real fwd ( Time  t) const

Definition at line 461 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the caller graph for this function:

◆ riskFreeRate()

const Handle< YieldTermStructure > & riskFreeRate ( ) const

Definition at line 466 of file andreasenhugevolatilityinterpl.cpp.

◆ calibrationError()

ext::tuple< Real, Real, Real > calibrationError ( ) const

Definition at line 471 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:

◆ optionPrice()

Real optionPrice ( Time  t,
Real  strike,
Option::Type  optionType 
) const

Definition at line 508 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ localVol()

Volatility localVol ( Time  t,
Real  strike 
) const

Definition at line 591 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprotectedvirtual

This method must implement any calculations which must be (re)done in order to calculate the desired results.

Implements LazyObject.

Definition at line 342 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:

◆ buildCostFunction()

ext::shared_ptr< AndreasenHugeCostFunction > buildCostFunction ( Size  iExpiry,
Option::Type  optionType,
const Array previousNPVs 
) const
private

Definition at line 287 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExerciseTimeIdx()

Size getExerciseTimeIdx ( Time  t) const
private

Definition at line 477 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the caller graph for this function:

◆ getCacheValue()

Real getCacheValue ( Real  strike,
const TimeValueCacheType::const_iterator &  f 
) const
private

Definition at line 484 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPriceSlice()

Array getPriceSlice ( Time  t,
Option::Type  optionType 
) const
private

Definition at line 496 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocalVolSlice()

Array getLocalVolSlice ( Time  t,
Option::Type  optionType 
) const
private

Definition at line 558 of file andreasenhugevolatilityinterpl.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ calibrationSet_

CalibrationSet calibrationSet_
private

Definition at line 123 of file andreasenhugevolatilityinterpl.hpp.

◆ spot_

const Handle<Quote> spot_
private

Definition at line 124 of file andreasenhugevolatilityinterpl.hpp.

◆ rTS_

const Handle<YieldTermStructure> rTS_
private

Definition at line 125 of file andreasenhugevolatilityinterpl.hpp.

◆ qTS_

const Handle<YieldTermStructure> qTS_
private

Definition at line 126 of file andreasenhugevolatilityinterpl.hpp.

◆ interpolationType_

const InterpolationType interpolationType_
private

Definition at line 127 of file andreasenhugevolatilityinterpl.hpp.

◆ calibrationType_

const CalibrationType calibrationType_
private

Definition at line 128 of file andreasenhugevolatilityinterpl.hpp.

◆ nGridPoints_

const Size nGridPoints_
private

Definition at line 130 of file andreasenhugevolatilityinterpl.hpp.

◆ minStrike_

const Real minStrike_
private

Definition at line 131 of file andreasenhugevolatilityinterpl.hpp.

◆ maxStrike_

const Real maxStrike_
private

Definition at line 131 of file andreasenhugevolatilityinterpl.hpp.

◆ optimizationMethod_

const ext::shared_ptr<OptimizationMethod> optimizationMethod_
private

Definition at line 133 of file andreasenhugevolatilityinterpl.hpp.

◆ endCriteria_

const EndCriteria endCriteria_
private

Definition at line 134 of file andreasenhugevolatilityinterpl.hpp.

◆ strikes_

std::vector<Real> strikes_
private

Definition at line 136 of file andreasenhugevolatilityinterpl.hpp.

◆ expiries_

std::vector<Date> expiries_
private

Definition at line 137 of file andreasenhugevolatilityinterpl.hpp.

◆ expiryTimes_

std::vector<Time> expiryTimes_
mutableprivate

Definition at line 138 of file andreasenhugevolatilityinterpl.hpp.

◆ dT_

std::vector<Time> dT_
private

Definition at line 138 of file andreasenhugevolatilityinterpl.hpp.

◆ calibrationMatrix_

std::vector<std::vector<Size> > calibrationMatrix_
private

Definition at line 140 of file andreasenhugevolatilityinterpl.hpp.

◆ avgError_

Real avgError_
mutableprivate

Definition at line 141 of file andreasenhugevolatilityinterpl.hpp.

◆ minError_

Real minError_
private

Definition at line 141 of file andreasenhugevolatilityinterpl.hpp.

◆ maxError_

Real maxError_
private

Definition at line 141 of file andreasenhugevolatilityinterpl.hpp.

◆ mesher_

ext::shared_ptr<FdmMesherComposite> mesher_
mutableprivate

Definition at line 143 of file andreasenhugevolatilityinterpl.hpp.

◆ gridPoints_

Array gridPoints_
mutableprivate

Definition at line 144 of file andreasenhugevolatilityinterpl.hpp.

◆ gridInFwd_

Array gridInFwd_
private

Definition at line 144 of file andreasenhugevolatilityinterpl.hpp.

◆ calibrationResults_

std::vector<SingleStepCalibrationResult> calibrationResults_
mutableprivate

Definition at line 146 of file andreasenhugevolatilityinterpl.hpp.

◆ localVolCache_

TimeValueCacheType localVolCache_
mutableprivate

Definition at line 148 of file andreasenhugevolatilityinterpl.hpp.

◆ priceCache_

TimeValueCacheType priceCache_
private

Definition at line 148 of file andreasenhugevolatilityinterpl.hpp.