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:

call_price

Price a single call option

maturity

Get a MaturityPricer from cache or create a new one and return it

plot3d

Plot the implied vols surface

reset

Clear the ttm cache

Attributes:

max_moneyness_ttm

Max time-adjusted moneyness to calculate prices

model

The stochastic process used for pricing

n

NUmber of discretization points for the marginal distribution

ttm

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

reset() None#

Clear the ttm cache

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:

black

Calculate the Maturity Result for the Black model with same std

call_price

Price a single call option

interp

get interpolated prices

max_moneyness_ttm

Calculate the implied volatility

plot

Plot the results

Attributes:

call

Call prices for the given :attr`.moneyness`

df

Get a dataframe with the results

implied_vols

Calculate the implied volatility

intrinsic_value

Intrinsic value of the option

moneyness

Moneyness as log Strike/Forward

moneyness_ttm

Time adjusted moneyness array

name

Name of the model

std

Standard deviation model of log returns

time_value

Time value of the option

ttm

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