Class FourierTransformPricer
Defined in File fourier_transform_pricer.hpp
Inheritance Relationships
Base Type
public otyca::StochasticProcessPricer
(Class StochasticProcessPricer)
Derived Types
public otyca::FFTPricer
(Class FFTPricer)public otyca::FRFTPricer
(Class FRFTPricer)
Class Documentation
-
class FourierTransformPricer : public otyca::StochasticProcessPricer
Option pricer using Fourier Transform.
This class implements a numerically efficient option pricing technique based on Fourier transform, as introduced by Peter Carr and Dilip B. Madan (1999) in “Option Valuation Using the Fast Fourier Transform.”
It computes option prices, derivatives, implied volatilities, and PDFs using the characteristic function of a given stochastic process.
Subclassed by otyca::FFTPricer, otyca::FRFTPricer
Public Functions
-
FourierTransformPricer(unsigned int, double, double)
-
virtual ~FourierTransformPricer()
-
virtual std::vector<std::vector<double>> price(const StochasticProcess*, const std::vector<double>&, const std::vector<std::vector<double>>&, StrikeType = LOG_STRIKE) const override
Prices for multiple tenors and strike sets.
- Parameters:
stochastic_process – Pointer to the stochastic process model.
tenors – Vector of tenors.
strikes – 2D vector of strikes (per tenor).
strike_type – Type of strike to use. See StrikeType for available options.
- Returns:
2D vector of prices.
-
virtual std::vector<std::vector<std::vector<double>>> price_derivatives(const StochasticProcess*, const std::vector<double>&, const std::vector<std::vector<double>>&, StrikeType = LOG_STRIKE) const override
Analytical price derivatives for each input.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Vector of tenors.
strikes – 2D strike array.
strike_type – Strike type to interpret. See StrikeType for available options.
- Returns:
3D vector of derivatives.
-
virtual std::vector<std::vector<double>> implied_volatility(const StochasticProcess*, const std::vector<double>&, const std::vector<std::vector<double>>&, StrikeType = LOG_STRIKE, double tolerance = 1e-4) const override
Implied volatilities for multiple tenors and strike sets.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Tenor vector.
strikes – 2D strike array.
strike_type – Strike type. See StrikeType for available options.
tolerance – Root-finding tolerance.
- Returns:
2D vector of implied volatilities.
-
virtual std::vector<std::vector<double>> pdf(const StochasticProcess*, const std::vector<double>&, const std::vector<std::vector<double>>&, StrikeType = LOG_STRIKE) const override
Returns PDFs for multiple tenors and strikes.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Vector of tenors.
strikes – 2D vector of strikes.
strike_type – Strike type. See StrikeType for available options.
- Returns:
2D vector of PDF values.
-
inline void get_u(arma::cx_colvec &u, arma::cx_colvec &iu, arma::cx_colvec &u2) const
-
double implied_volatility(const StochasticProcess *stochastic_process, double tenor, double strike, StrikeType strike_type = LOG_STRIKE, double tolerance = 1e-4) const
Calculates implied volatility for one option.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenor – Tenor.
strike – Strike.
strike_type – Strike type. See StrikeType for available options.
tolerance – Root-finding tolerance.
- Returns:
Implied volatility.
-
std::vector<double> implied_volatility(const StochasticProcess *stochastic_process, double tenor, const std::vector<double> &strikes, StrikeType strike_type = LOG_STRIKE, double tolerance = 1e-4) const
Implied volatilities for a vector of strikes at a given tenor.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenor – Tenor.
strikes – Strike vector.
strike_type – Strike type. See StrikeType for available options.
tolerance – Root-finding tolerance.
- Returns:
Vector of implied volatilities.
-
virtual std::vector<std::vector<double>> implied_volatility(const StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type = LOG_STRIKE, double tolerance = 1e-4) const = 0
Implied volatilities for multiple tenors and strike sets.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Tenor vector.
strikes – 2D strike array.
strike_type – Strike type. See StrikeType for available options.
tolerance – Root-finding tolerance.
- Returns:
2D vector of implied volatilities.
-
double pdf(const StochasticProcess *stochastic_process, double tenor, double strike, StrikeType strike_type = LOG_STRIKE) const
Returns PDF value at a given tenor and strike.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenor – Tenor.
strike – Strike.
strike_type – Strike type. See StrikeType for available options.
- Returns:
PDF value.
-
std::vector<double> pdf(const StochasticProcess *stochastic_process, double tenor, const std::vector<double> &strikes, StrikeType strike_type = LOG_STRIKE) const
Returns PDF values for a vector of strikes.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenor – Tenor.
strikes – Strike vector.
strike_type – Strike type. See StrikeType for available options.
- Returns:
Vector of PDF values.
-
virtual std::vector<std::vector<double>> pdf(const StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type = LOG_STRIKE) const = 0
Returns PDFs for multiple tenors and strikes.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Vector of tenors.
strikes – 2D vector of strikes.
strike_type – Strike type. See StrikeType for available options.
- Returns:
2D vector of PDF values.
Protected Functions
-
virtual void _price_kernal(const StochasticProcess*, const arma::rowvec &expirations) const = 0
-
virtual std::vector<arma::mat> _price_derivatives_kernal(const StochasticProcess*, const arma::rowvec &tenors) const = 0
-
virtual void _pdf_kernal(const StochasticProcess*, const arma::rowvec &expirations) const = 0
-
void _interpolate(const StochasticProcess*, const std::vector<double>&, const std::vector<std::vector<double>>&, std::vector<std::vector<double>>&, StrikeType, YType) const
-
void _interpolate(const arma::colvec *xs, const arma::mat *ys, const std::vector<std::vector<double>> &strikes, std::vector<std::vector<double>> &values) const
-
void _calls_to_vols(const StochasticProcess*, double tolerance = 1e-4) const
-
void _cn_to_calls(const StochasticProcess *process) const
Protected Attributes
-
unsigned int _n
-
double _lambda
-
double _eta
-
arma::cx_colvec _scaler
-
arma::cx_colvec _um
-
arma::cx_colvec _iu
-
arma::cx_colvec _u2
-
double *_x
-
double *_y
-
double *_u
-
double *_ya
-
arma::colvec _kj
-
arma::colvec _kn
-
mutable arma::rowvec _expirations
-
mutable arma::mat _vn
-
mutable arma::mat _cn
-
mutable arma::mat _calls
-
mutable arma::mat _pdf
-
std::shared_ptr<FourierTransform> _ft
-
arma::colvec _dampen_factor
-
FourierTransformPricer(unsigned int, double, double)