Option Pricer#
The option pricer module provides classes for pricing options using different stochastic volatility models.
- class quantflow.options.pricer.OptionPricer(model: ~quantflow.options.pricer.M, ttm: dict[int, ~quantflow.options.pricer.MaturityPricer] = <factory>, n: int = 128, max_moneyness_ttm: float = 1.5)#
Pricer for options
Methods:
Price a single call option
Get a
MaturityPricer
from cache or create a new one and return itPlot the implied vols surface
Clear the
ttm
cacheAttributes:
Max time-adjusted moneyness to calculate prices
The stochastic process used for pricing
NUmber of discretization points for the marginal distribution
Cache for
MaturityPricer
for different time to maturity- call_price(ttm: float, moneyness: float) float #
Price a single call option
- Parameters:
ttm – Time to maturity
moneyness – Moneyness as log(Strike/Forward)
This method will use the cache to get the maturity pricer if possible
- maturity(ttm: float, **kwargs: Any) MaturityPricer #
Get a
MaturityPricer
from cache or create a new one and return it
- plot3d(max_moneyness_ttm: float = 1.0, support: int = 51, ttm: ndarray[tuple[int, ...], dtype[floating[Any]]] | None = None, **kwargs: Any) Any #
Plot the implied vols surface
It requires plotly to be installed
- max_moneyness_ttm: float = 1.5#
Max time-adjusted moneyness to calculate prices
- model: M#
The stochastic process used for pricing
- n: int = 128#
NUmber of discretization points for the marginal distribution
- ttm: dict[int, MaturityPricer]#
Cache for
MaturityPricer
for different time to maturity
- class quantflow.options.pricer.MaturityPricer(ttm: float, std: float, moneyness: FloatArray, call: FloatArray, name: str = '')#
Result of option pricing for a given Time to Maturity
Methods:
Calculate the Maturity Result for the Black model with same std
Price a single call option
get interpolated prices
Calculate the implied volatility
Plot the results
Attributes:
Call prices for the given :attr`.moneyness`
Get a dataframe with the results
Calculate the implied volatility
Intrinsic value of the option
Moneyness as log Strike/Forward
Time adjusted moneyness array
Name of the model
Standard deviation model of log returns
Time value of the option
Time to Maturity
- black() MaturityPricer #
Calculate the Maturity Result for the Black model with same std
- call_price(moneyness: float) float #
Price a single call option
- interp(moneyness: ndarray[tuple[int, ...], dtype[floating[Any]]]) MaturityPricer #
get interpolated prices
- max_moneyness_ttm(max_moneyness_ttm: float = 1.0, support: int = 51) MaturityPricer #
Calculate the implied volatility
- plot(series: str = 'implied_vol', **kwargs: Any) Any #
Plot the results
- call: ndarray[tuple[int, ...], dtype[floating[Any]]]#
Call prices for the given :attr`.moneyness`
- property df: DataFrame#
Get a dataframe with the results
- property implied_vols: ndarray[tuple[int, ...], dtype[floating[Any]]]#
Calculate the implied volatility
- property intrinsic_value: ndarray[tuple[int, ...], dtype[floating[Any]]]#
Intrinsic value of the option
- moneyness: ndarray[tuple[int, ...], dtype[floating[Any]]]#
Moneyness as log Strike/Forward
- property moneyness_ttm: ndarray[tuple[int, ...], dtype[floating[Any]]]#
Time adjusted moneyness array
- name: str#
Name of the model
- std: float#
Standard deviation model of log returns
- property time_value: ndarray[tuple[int, ...], dtype[floating[Any]]]#
Time value of the option
- ttm: float#
Time to Maturity