Class StochasticProcessPricer
Defined in File stochastic_process_pricer.hpp
Inheritance Relationships
Derived Types
public otyca::AutoStochasticProcessPricer
(Class AutoStochasticProcessPricer)public otyca::DirectIntegrationPricer
(Class DirectIntegrationPricer)public otyca::FourierTransformPricer
(Class FourierTransformPricer)
Class Documentation
-
class StochasticProcessPricer
Abstract base class for pricing instruments under a stochastic process.
Subclassed by otyca::AutoStochasticProcessPricer, otyca::DirectIntegrationPricer, otyca::FourierTransformPricer
Public Types
Public Functions
-
virtual ~StochasticProcessPricer()
-
virtual std::string name() = 0
Returns the name of the pricer.
- Returns:
The name as a string.
-
virtual std::vector<std::vector<double>> price(const StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type = LOG_STRIKE) const = 0
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 *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type = LOG_STRIKE) const = 0
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<std::vector<double>>> price_derivatives_finite_difference(const StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type = LOG_STRIKE, double epsilon = 1e-6) const
Price derivatives using finite differences.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Vector of tenors.
strikes – 2D strike array.
strike_type – Strike type. See StrikeType for available options.
epsilon – Finite difference step size.
- Returns:
3D vector of approximated derivatives.
-
bool compare_price_derivatives(const StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type = LOG_STRIKE, double epsilon = 1e-6, double tolerance = 1e-6)
Compares analytical and finite-difference derivatives.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Vector of tenors.
strikes – 2D strike array.
strike_type – Strike type. See StrikeType for available options.
epsilon – FD step size.
tolerance – Acceptable error.
- Returns:
true if all derivatives are within tolerance.
-
std::vector<double> price(const StochasticProcess *stochastic_process, double tenor, const std::vector<double> &strikes, StrikeType strike_type = LOG_STRIKE) const
Prices for a single tenor and set of strikes.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenor – Single tenor value.
strikes – Strike vector.
strike_type – Strike type. See StrikeType for available options.
- Returns:
Vector of prices.
-
double price(const StochasticProcess *stochastic_process, double tenor, double strike, StrikeType strike_type = LOG_STRIKE) const
Prices a single option.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenor – Tenor value.
strike – Strike value.
strike_type – Strike type.
- Returns:
Option price.
-
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.
-
void measure_stochastic_process(StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, const std::vector<std::vector<double>> &weights, const std::vector<double> ¶meters, arma::colvec &result)
Measures model by weighting results over strikes and tenors.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Vector of tenors.
strikes – 2D strike array.
weights – 2D weights for each strike.
parameters – Model parameters.
result – Output column vector to fill.
-
inline const arma::colvec &get_u()
Gets the u values.
- Returns:
Column vector of u values.
-
inline const arma::colvec &get_u2()
Gets the u^2 values.
- Returns:
Column vector of u squared values.
-
inline const arma::cx_colvec &get_iu()
Gets the imaginary u values.
- Returns:
Complex column vector of i*u values.
-
inline const arma::colvec &get_logu()
Gets the log(u) values.
- Returns:
Column vector of log(u) values.
-
inline const arma::rowvec &get_t()
Gets the t values.
- Returns:
Row vector of t values.
Protected Functions
-
void _pdf_transformation(const StochasticProcess *stochastic_process, const std::vector<double> &tenors, const std::vector<std::vector<double>> &strikes, StrikeType strike_type, std::vector<std::vector<double>> &pdfs) const
Computes PDF values for given parameters and stores in output.
- Parameters:
stochastic_process – Pointer to stochastic process.
tenors – Tenor values.
strikes – Strike values.
strike_type – Strike interpretation.
pdfs – Output PDF values.
-
virtual ~StochasticProcessPricer()