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 | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
AnalyticHestonEngine Class Reference

analytic Heston-model engine based on Fourier transform More...

#include <analytichestonengine.hpp>

+ Inheritance diagram for AnalyticHestonEngine:
+ Collaboration diagram for AnalyticHestonEngine:

Classes

class  AP_Helper
 
class  Integration
 
class  OptimalAlpha
 

Public Types

enum  ComplexLogFormula {
  Gatheral , BranchCorrection , AndersenPiterbarg , AndersenPiterbargOptCV ,
  AsymptoticChF , AngledContour , AngledContourNoCV , OptimalCV
}
 
- Public Types inherited from Observer
typedef set_type::iterator iterator
 

Public Member Functions

 AnalyticHestonEngine (const ext::shared_ptr< HestonModel > &model, Real relTolerance, Size maxEvaluations)
 
 AnalyticHestonEngine (const ext::shared_ptr< HestonModel > &model, Size integrationOrder=144)
 
 AnalyticHestonEngine (const ext::shared_ptr< HestonModel > &model, ComplexLogFormula cpxLog, const Integration &itg, Real andersenPiterbargEpsilon=1e-25, Real alpha=-0.5)
 
void calculate () const override
 
std::complex< RealchF (const std::complex< Real > &z, Time t) const
 
std::complex< ReallnChF (const std::complex< Real > &z, Time t) const
 
Size numberOfEvaluations () const
 
Real priceVanillaPayoff (const ext::shared_ptr< PlainVanillaPayoff > &payoff, const Date &maturity) const
 
Real priceVanillaPayoff (const ext::shared_ptr< PlainVanillaPayoff > &payoff, Time maturity) const
 
- Public Member Functions inherited from GenericModelEngine< HestonModel, VanillaOption::arguments, VanillaOption::results >
 GenericModelEngine (Handle< HestonModel > model=Handle< HestonModel >())
 
 GenericModelEngine (const ext::shared_ptr< HestonModel > &model)
 
- Public Member Functions inherited from GenericEngine< ArgumentsType, ResultsType >
PricingEngine::argumentsgetArguments () const override
 
const PricingEngine::resultsgetResults () const override
 
void reset () override
 
void update () override
 
- Public Member Functions inherited from PricingEngine
 ~PricingEngine () override=default
 
virtual argumentsgetArguments () const =0
 
virtual const resultsgetResults () const =0
 
virtual void reset ()=0
 
virtual void calculate () const =0
 
- 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 ()
 

Static Public Member Functions

static void doCalculation (Real riskFreeDiscount, Real dividendDiscount, Real spotPrice, Real strikePrice, Real term, Real kappa, Real theta, Real sigma, Real v0, Real rho, const TypePayoff &type, const Integration &integration, ComplexLogFormula cpxLog, const AnalyticHestonEngine *enginePtr, Real &value, Size &evaluations)
 
static ComplexLogFormula optimalControlVariate (Time t, Real v0, Real kappa, Real theta, Real sigma, Real rho)
 

Protected Member Functions

virtual std::complex< RealaddOnTerm (Real phi, Time t, Size j) const
 

Private Member Functions

Real priceVanillaPayoff (const ext::shared_ptr< PlainVanillaPayoff > &payoff, Time maturity, Real fwd) const
 

Private Attributes

Size evaluations_
 
const ComplexLogFormula cpxLog_
 
const ext::shared_ptr< Integrationintegration_
 
const Real andersenPiterbargEpsilon_
 
const Real alpha_
 

Additional Inherited Members

- Protected Attributes inherited from GenericModelEngine< HestonModel, VanillaOption::arguments, VanillaOption::results >
Handle< HestonModelmodel_
 
- Protected Attributes inherited from GenericEngine< ArgumentsType, ResultsType >
ArgumentsType arguments_
 
ResultsType results_
 

Detailed Description

analytic Heston-model engine based on Fourier transform

Integration detail: Two algebraically equivalent formulations of the complex logarithm of the Heston model exist. Gatherals [2005] (also Duffie, Pan and Singleton [2000], and Schoutens, Simons and Tistaert[2004]) version does not cause discoutinuities whereas the original version (e.g. Heston [1993]) needs some sort of "branch correction" to work properly. Gatheral's version does also work with adaptive integration routines and should be preferred over the original Heston version.

References:

Heston, Steven L., 1993. A Closed-Form Solution for Options with Stochastic Volatility with Applications to Bond and Currency Options. The review of Financial Studies, Volume 6, Issue 2, 327-343.

A. Sepp, Pricing European-Style Options under Jump Diffusion Processes with Stochastic Volatility: Applications of Fourier Transform (http://math.ut.ee/~spartak/papers/stochjumpvols.pdf)

R. Lord and C. Kahl, Why the rotation count algorithm works, http://papers.ssrn.com/sol3/papers.cfm?abstract_id=921335

H. Albrecher, P. Mayer, W.Schoutens and J. Tistaert, The Little Heston Trap, http://www.schoutens.be/HestonTrap.pdf

J. Gatheral, The Volatility Surface: A Practitioner's Guide, Wiley Finance

F. Le Floc'h, Fourier Integration and Stochastic Volatility Calibration, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2362968

L. Andersen, and V. Piterbarg, 2010, Interest Rate Modeling, Volume I: Foundations and Vanilla Models, Atlantic Financial Press London.

L. Andersen and M. Lake, 2018 Robust High-Precision Option Pricing by Fourier Transforms: Contour Deformations and Double-Exponential Quadrature, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3231626

Tests:
the correctness of the returned value is tested by reproducing results available in web/literature and comparison with Black pricing.

Definition at line 91 of file analytichestonengine.hpp.

Member Enumeration Documentation

◆ ComplexLogFormula

Enumerator
Gatheral 
BranchCorrection 
AndersenPiterbarg 
AndersenPiterbargOptCV 
AsymptoticChF 
AngledContour 
AngledContourNoCV 
OptimalCV 

Definition at line 100 of file analytichestonengine.hpp.

Constructor & Destructor Documentation

◆ AnalyticHestonEngine() [1/3]

AnalyticHestonEngine ( const ext::shared_ptr< HestonModel > &  model,
Real  relTolerance,
Size  maxEvaluations 
)

Definition at line 673 of file analytichestonengine.cpp.

◆ AnalyticHestonEngine() [2/3]

AnalyticHestonEngine ( const ext::shared_ptr< HestonModel > &  model,
Size  integrationOrder = 144 
)

Definition at line 659 of file analytichestonengine.cpp.

◆ AnalyticHestonEngine() [3/3]

AnalyticHestonEngine ( const ext::shared_ptr< HestonModel > &  model,
ComplexLogFormula  cpxLog,
const Integration itg,
Real  andersenPiterbargEpsilon = 1e-25,
Real  alpha = -0.5 
)

Definition at line 687 of file analytichestonengine.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ calculate()

void calculate ( ) const
overridevirtual

Implements PricingEngine.

Reimplemented in AnalyticHestonHullWhiteEngine.

Definition at line 861 of file analytichestonengine.cpp.

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

◆ chF()

std::complex< Real > chF ( const std::complex< Real > &  z,
Time  t 
) const

Definition at line 578 of file analytichestonengine.cpp.

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

◆ lnChF()

std::complex< Real > lnChF ( const std::complex< Real > &  z,
Time  t 
) const

Definition at line 621 of file analytichestonengine.cpp.

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

◆ numberOfEvaluations()

Size numberOfEvaluations ( ) const

Definition at line 721 of file analytichestonengine.cpp.

◆ doCalculation()

void doCalculation ( Real  riskFreeDiscount,
Real  dividendDiscount,
Real  spotPrice,
Real  strikePrice,
Real  term,
Real  kappa,
Real  theta,
Real  sigma,
Real  v0,
Real  rho,
const TypePayoff type,
const Integration integration,
ComplexLogFormula  cpxLog,
const AnalyticHestonEngine enginePtr,
Real value,
Size evaluations 
)
static

Definition at line 1068 of file analytichestonengine.cpp.

+ Here is the call graph for this function:

◆ priceVanillaPayoff() [1/3]

Real priceVanillaPayoff ( const ext::shared_ptr< PlainVanillaPayoff > &  payoff,
const Date maturity 
) const

Definition at line 725 of file analytichestonengine.cpp.

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

◆ priceVanillaPayoff() [2/3]

Real priceVanillaPayoff ( const ext::shared_ptr< PlainVanillaPayoff > &  payoff,
Time  maturity 
) const

Definition at line 737 of file analytichestonengine.cpp.

+ Here is the call graph for this function:

◆ optimalControlVariate()

AnalyticHestonEngine::ComplexLogFormula optimalControlVariate ( Time  t,
Real  v0,
Real  kappa,
Real  theta,
Real  sigma,
Real  rho 
)
static

Definition at line 708 of file analytichestonengine.cpp.

+ Here is the caller graph for this function:

◆ addOnTerm()

std::complex< Real > addOnTerm ( Real  phi,
Time  t,
Size  j 
) const
protectedvirtual

◆ priceVanillaPayoff() [3/3]

Real priceVanillaPayoff ( const ext::shared_ptr< PlainVanillaPayoff > &  payoff,
Time  maturity,
Real  fwd 
) const
private

Definition at line 748 of file analytichestonengine.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ evaluations_

Size evaluations_
mutableprivate

Definition at line 191 of file analytichestonengine.hpp.

◆ cpxLog_

const ComplexLogFormula cpxLog_
private

Definition at line 192 of file analytichestonengine.hpp.

◆ integration_

const ext::shared_ptr<Integration> integration_
private

Definition at line 193 of file analytichestonengine.hpp.

◆ andersenPiterbargEpsilon_

const Real andersenPiterbargEpsilon_
private

Definition at line 194 of file analytichestonengine.hpp.

◆ alpha_

const Real alpha_
private

Definition at line 194 of file analytichestonengine.hpp.