Class OptionExpiration

Inheritance Relationships

Base Type

  • public std::enable_shared_from_this< OptionExpiration >

Class Documentation

class OptionExpiration : public std::enable_shared_from_this<OptionExpiration>

Represents a collection of all options for an option expiration.

Public Functions

OptionExpiration(const boost::posix_time::ptime &expiration, const std::shared_ptr<UnderlyingDataset> &underlying_dataset)

Constructs an OptionExpiration object.

Parameters:
  • expiration – The expiration time.

  • underlying_dataset – The underlying dataset.

void setup()

Initializes the option expiration.

std::shared_ptr<OptionStrike> atm_option_strike() const

Retrieves the at-the-money option strike.

Returns:

A shared pointer to the at-the-money option strike.

std::vector<std::shared_ptr<OptionStrike>> get_option_strikes(const ObjectGetter<bool, OptionStrike> &filter = [](std::shared_ptr< OptionStrike >) { return true;}) const

Retrieves a list of option strikes that satisfy the given filter criteria.

Parameters:

filter – A callable object that takes a std::shared_ptr<OptionStrike> as input and returns a boolean indicating whether the strike should be included in the result. Defaults to including all strikes.

Returns:

A vector of shared pointers to OptionStrike objects that satisfy the filter criteria.

std::shared_ptr<Option> create_option(double strike, OptionType type)

Creates a new option that belongs to this expiration with the specified strike price and option type.

Parameters:
  • strike – The strike price of the option.

  • type – The type of the option (e.g., call or put).

Returns:

A shared pointer to the newly created Option object.

template<typename T>
inline std::vector<T> get_strike_values(const ObjectGetter<T, OptionStrike> &value_getter, const ObjectGetter<bool, OptionStrike> &filter = [](std::shared_ptr< OptionStrike >) { return true;}) const

Retrieves a list of option strike values satisfying a given filter on option strikes.

Template Parameters:

T – The return type.

Parameters:
  • value_getter – Function to extract values from OptionStrike objects.

  • filter – Function to filter OptionStrike objects.

Returns:

A vector of extracted values.

inline bool not_expired() const

Checks if the option expiration has not expired.

Returns:

True if not expired, false otherwise.

inline bool expired() const

Checks if the option expiration has expired.

Returns:

True if expired, false otherwise.

inline boost::posix_time::ptime get_expiration() const

Gets the expiration time.

Returns:

The expiration time.

inline void set_expiration(boost::posix_time::ptime expiration)

Sets the expiration time.

Parameters:

expiration – The new expiration time.

inline Estimate get_forward() const

Gets the estimated forward price.

Returns:

The forward price estimate.

inline double get_forward_value() const

Gets the forward price value.

Returns:

The forward price value.

inline double get_forward_uncertainty() const

Gets the forward price uncertainty.

Returns:

The forward price uncertainty.

inline Estimate get_interest_rate() const

Retrieves the interest rate estimate.

Returns:

The interest rate as an Estimate object.

inline double get_interest_rate_value() const

Retrieves the numerical value of the interest rate.

Returns:

The interest rate value as a double.

inline double get_interest_rate_uncertainty() const

Retrieves the uncertainty of the interest rate estimate.

Returns:

The uncertainty in the interest rate as a double.

inline Estimate get_borrow_rate() const

Retrieves the borrow rate estimate.

Returns:

The borrow rate as an Estimate object.

inline double get_borrow_rate_value() const

Retrieves the numerical value of the borrow rate.

Returns:

The borrow rate value as a double.

inline double get_borrow_rate_uncertainty() const

Retrieves the uncertainty of the borrow rate estimate.

Returns:

The uncertainty in the borrow rate as a double.

inline StrikeMap get_strikes() const

Retrieves the all the option strikes with this expiration.

Returns:

A map with strike value times strike multiplier as the key and option strike shared pointer as value.

inline unsigned int get_n_strikes() const

Retrieves the number of option strikes.

Returns:

The number of option strikes as an unsigned integer.

inline double get_event_tenor() const

Retrieves the event tenor.

Returns:

The event tenor as a double.

inline double get_variance_tenor() const

Retrieves the variance tenor.

Returns:

The variance tenor as a double.

inline double get_hedge_tenor() const

Retrieves the hedge tenor.

Returns:

The hedge tenor as a double.

inline double get_carry_tenor() const

Retrieves the carry tenor.

Returns:

The carry tenor as a double.

void get_options(std::vector<std::shared_ptr<Option>> &options) const

Retrieves the all the options with this expiration.

Parameters:

options[out] A vector to store the retrieved options.

inline double get_vix_style_volatility() const

Retrieves the VIX-style volatility.

Returns:

The VIX-style volatility as a double.

inline const Estimate &get_implied_forward() const

Retrieves the implied forward estimate.

Returns:

A constant reference to the implied forward estimate.

inline double get_implied_forward_value() const

Retrieves the numerical value of the implied forward.

Returns:

The implied forward value as a double.

inline double get_implied_forward_uncertainty() const

Retrieves the uncertainty of the implied forward estimate.

Returns:

The uncertainty in the implied forward as a double.

inline double get_accumulated_fixed_dividend() const

Retrieves the accumulated fixed dividend upto this expiration.

Returns:

The accumulated fixed dividend as a double.

inline double get_accumulated_proportional_dividend() const

Retrieves the accumulated proportional dividend upto this expiration.

Returns:

The accumulated proportional dividend as a double.

inline Dividend get_accumulated_dividend() const

Retrieves the accumulated dividend upto this expiration.

Returns:

The accumulated dividend as a Dividend object.

inline Estimate get_atm_volatility() const

Retrieves the at-the-money (ATM) volatility estimate.

Returns:

The ATM volatility as an Estimate object.

Estimate get_atm_variance() const

Retrieves the at-the-money (ATM) variance estimate.

Returns:

The ATM variance as an Estimate object.

double get_atm_volatility_value() const

Retrieves the numerical value of the ATM volatility.

Returns:

The ATM volatility value as a double.

double get_fair_atm_volatility() const

Retrieves the fair at-the-money (ATM) volatility.

Returns:

The fair ATM volatility as a double.

double get_stochastic_process_atm_volatility() const

Retrieves the stochastic process ATM volatility.

Returns:

The stochastic process ATM volatility as a double.

double atm_volatility(std::shared_ptr<StochasticProcess> stochastic_process)

For a given stochastic process, calculate forward ATM volatility.

Returns:

Forward ATM volatility

double variance(std::shared_ptr<StochasticProcess> stochastic_process)

For a given stochastic process, calculate variance.

Returns:

variance

double get_fair_1_stdev_call_volatility() const

Retrieves the fair volatility at 1-standard deviation call strike.

Returns:

The fair 1-standard deviation call volatility as a double.

double get_fair_1_stdev_put_volatility() const

Retrieves the fair volatility at 1-standard deviation put strike.

Returns:

The fair 1-standard deviation put volatility as a double.

double get_fair_volatility_skew() const

Retrieves the fair volatility skew.

Returns:

The fair volatility skew as a double.

double get_fair_volatility_model_reduced_chi2() const

Retrieves the fair volatility model fitting chi2.

Returns:

The fair volatility model fitting chi2 as a double.

double stochastic_process_atm_volatility(std::shared_ptr<const StochasticProcess> process) const

Computes the stochastic process ATM volatility.

Parameters:

process[in] A shared pointer to the stochastic process.

Returns:

The stochastic process ATM volatility as a double.

double stochastic_process_1_stdev_call_volatility(std::shared_ptr<const StochasticProcess> process) const

Computes the stochastic process volatility at 1-standard deviation call strike.

Parameters:

process[in] A shared pointer to the stochastic process.

Returns:

The stochastic process 1-standard deviation call volatility as a double.

double stochastic_process_1_stdev_put_volatility(std::shared_ptr<const StochasticProcess> process) const

Computes the stochastic process volatility at 1-standard deviation put strike.

Parameters:

process[in] A shared pointer to the stochastic process.

Returns:

The stochastic process 1-standard deviation put volatility as a double.

double get_variance_term_structure_model_value() const

Retrieves the variance term structure model value.

Returns:

The variance term structure model value as a double.

double get_atm_volatility_uncertainty() const

Retrieves the uncertainty of the at-the-money (ATM) volatility.

Returns:

The ATM volatility uncertainty as a double.

std::shared_ptr<Model<1>> get_fair_volatility_model() const

Retrieves the fair volatility model.

Returns:

A shared pointer to the fair volatility model.

inline auto get_sabr_volatility_model() const

Retrieves the SABR volatility model.

Returns:

The SABR volatility model.

inline auto get_simplified_svi_volatility_model() const

Retrieves the simplified SVI volatility model.

Returns:

The simplified SVI volatility model.

inline auto get_affine_svi_volatility_model() const

Retrieves the Affine SVI volatility model.

Returns:

The Affine SVI volatility model.

inline auto get_svi_volatility_model() const

Retrieves the SVI volatility model.

Returns:

The SVI volatility model.

inline auto get_quadratic_svi_volatility_model() const

Retrieves the quadratic SVI volatility model.

Returns:

The quadratic SVI volatility model.

inline auto get_polynomial0_volatility_model() const

Retrieves the polynomial0 volatility model.

Returns:

The 0th order(flat) polynomial volatility model.

inline auto get_polynomial1_volatility_model() const

Retrieves the polynomial1 volatility model.

Returns:

The 1st order(linear) polynomial volatility model.

inline auto get_polynomial2_volatility_model() const

Retrieves the polynomial2 volatility model.

Returns:

The 2nc order polynomial volatility model.

inline auto get_cubic_spline_volatility_model() const

Retrieves the cubic spline volatility model.

Returns:

The cubic spline volatility model.

inline auto get_composite_volatility_model() const

Retrieves the composite volatility model.

Returns:

The composite volatility model.

inline std::shared_ptr<StochasticProcess> get_stochastic_process() const

Retrieves the stochastic process used in the model.

Returns:

A shared pointer to the stochastic process.

std::shared_ptr<OptionStrike> lowest_strike_with_bid_ask_volatility() const

Retrieves the lowest option strike with valid bid-ask volatility.

Returns:

A shared pointer to the lowest strike with bid-ask volatility.

std::shared_ptr<OptionStrike> highest_strike_with_bid_ask_volatility() const

Retrieves the highest option strike with valid bid-ask volatility.

Returns:

A shared pointer to the highest strike with bid-ask volatility.

std::shared_ptr<OptionStrike> lowest_strike_with_put_bid_ask_volatility() const

Retrieves the lowest option strike with valid put bid-ask volatility.

Returns:

A shared pointer to the lowest strike with put bid-ask volatility.

std::shared_ptr<OptionStrike> highest_strike_with_call_bid_ask_volatility() const

Retrieves the highest option strike with valid call bid-ask volatility.

Returns:

A shared pointer to the highest strike with call bid-ask volatility.

std::tuple<std::vector<double>, std::vector<std::string>, std::vector<std::vector<double>>> get_option_strike_dataframe() const

Retrieves a structured representation of option strike data.

Returns:

A tuple containing vectors of option strike values, labels, and additional data.

Estimate implied_borrow(std::shared_ptr<Schedule<Dividend>> dividend_schedule, double interest_rate, double borrow_tolerance = 1e-4, double relative_forward_tolerance = 1e-4)

Computes the implied borrow rate given a dividend schedule and an interest rate.

Parameters:
  • dividend_schedule[in] A shared pointer to the dividend schedule.

  • interest_rate[in] The interest rate used for calculation.

  • borrow_tolerance[in] Tolerance for the borrow rate estimation.

  • relative_forward_tolerance[in] Tolerance for the relative forward price.

Returns:

The estimated implied borrow rate.

Estimate implied_interest(std::shared_ptr<Schedule<Dividend>> dividend_schedule, double borrow_rate, double rate_tolerance = 1e-4, double relative_forward_tolerance = 1e-4)

Computes the implied interest rate given a dividend schedule and a borrow rate.

Parameters:
  • dividend_schedule[in] A shared pointer to the dividend schedule.

  • borrow_rate[in] The borrow rate used for calculation.

  • rate_tolerance[in] Tolerance for the interest rate estimation.

  • relative_forward_tolerance[in] Tolerance for the relative forward price.

Returns:

The estimated implied interest rate.

inline std::pair<Estimate, Estimate> get_implied_interest_borrow() const

Retrieves the implied interest and borrow rate estimates.

Returns:

A pair containing the implied interest and borrow rate estimates.

inline double get_implied_interest_value() const

Retrieves the numerical value of the implied interest rate.

Returns:

The implied interest rate value as a double.

inline double get_implied_borrow_value() const

Retrieves the numerical value of the implied borrow rate.

Returns:

The implied borrow rate value as a double.

inline double get_implied_interest_uncertainty() const

Retrieves the uncertainty of the implied interest rate estimate.

Returns:

The uncertainty in the implied interest rate as a double.

inline double get_implied_borrow_uncertainty() const

Retrieves the uncertainty of the implied borrow rate estimate.

Returns:

The uncertainty in the implied borrow rate as a double.

void reset()

Resets the internal state of the object.

inline std::shared_ptr<OptionCalculator<SPOT_VOLATILITY>> get_option_calculator()

Retrieves the option calculator for Greeks calculation.

Returns:

A shared pointer to the option calculator.

inline std::shared_ptr<OptionCalculator<SPOT_VOLATILITY>> get_implied_option_calculator()

Retrieves the option calculator for implied volatility calculation.

Returns:

A shared pointer to the option calculator.

double _implied_interest_borrow_search(std::pair<Estimate, Estimate>&, std::shared_ptr<Schedule<Dividend>>)

Public Static Functions

static inline std::map<std::string, ObjectGetter<double, OptionExpiration>> _get_option_expiration_value_functions()

Friends

friend std::ostream &operator<<(std::ostream&, const OptionExpiration&)