Option Pricer¶
The option pricer module provides classes for pricing options using different stochastic volatility models.
quantflow.options.pricer.OptionPricerBase
pydantic-model
¶
Bases: BaseModel
Abstract base class for option pricers.
Provides caching of MaturityPricer
results and generic pricing/plotting methods. Subclasses implement
_compute_maturity to define how call prices are computed for a given
time to maturity.
Fields:
-
ttm(dict[int, MaturityPricer])
reset
¶
maturity
¶
Get a MaturityPricer from cache or compute a new one and return it
Source code in quantflow/options/pricer.py
price
¶
Price a single option
This method will use the cache to get the maturity pricer if possible
| PARAMETER | DESCRIPTION |
|---|---|
option_type
|
Type of the option (call or put)
TYPE:
|
ttm
|
Time to maturity
TYPE:
|
strike
|
Strike price of the option
TYPE:
|
forward
|
Forward price of the underlying
TYPE:
|
Source code in quantflow/options/pricer.py
call_prices
¶
Price a batch of call options.
Options are grouped by their ttm so each unique maturity pricer is
retrieved (and cached) once and the corresponding log-strikes are
interpolated in a single vectorised np.interp call.
| PARAMETER | DESCRIPTION |
|---|---|
ttms
|
Vector of time to maturities
TYPE:
|
log_strikes
|
Vector of log-strikes log(K/F)
TYPE:
|
Source code in quantflow/options/pricer.py
plot3d
¶
Plot the implied vols surface
It requires plotly to be installed
Source code in quantflow/options/pricer.py
quantflow.options.pricer.OptionPricer
pydantic-model
¶
Bases: OptionPricerBase, Generic[M]
Pricer for options based on a stochastic process model.
Computes call prices via the inverse Fourier transform of the call option transform function of the underlying stochastic process.
Fields:
-
ttm(dict[int, MaturityPricer]) -
model(M) -
n(int) -
method(OptionPricingMethod) -
cos_moneyness_std_precision(float) -
max_moneyness(float)
cos_moneyness_std_precision
pydantic-field
¶
the accuracy of the COS method in number of std at a given TTM
max_moneyness
pydantic-field
¶
Maximum time-scaled moneyness to use for the pricing grid. Only used if method is Lewis or Carr & Madan, otherwise ignored.
reset
¶
maturity
¶
Get a MaturityPricer from cache or compute a new one and return it
Source code in quantflow/options/pricer.py
price
¶
Price a single option
This method will use the cache to get the maturity pricer if possible
| PARAMETER | DESCRIPTION |
|---|---|
option_type
|
Type of the option (call or put)
TYPE:
|
ttm
|
Time to maturity
TYPE:
|
strike
|
Strike price of the option
TYPE:
|
forward
|
Forward price of the underlying
TYPE:
|
Source code in quantflow/options/pricer.py
call_prices
¶
Price a batch of call options.
Options are grouped by their ttm so each unique maturity pricer is
retrieved (and cached) once and the corresponding log-strikes are
interpolated in a single vectorised np.interp call.
| PARAMETER | DESCRIPTION |
|---|---|
ttms
|
Vector of time to maturities
TYPE:
|
log_strikes
|
Vector of log-strikes log(K/F)
TYPE:
|
Source code in quantflow/options/pricer.py
plot3d
¶
Plot the implied vols surface
It requires plotly to be installed
Source code in quantflow/options/pricer.py
quantflow.options.pricer.MaturityPricer
pydantic-model
¶
Bases: BaseModel
Result of option pricing for a given Time to Maturity
Fields:
-
ttm(float) -
pricing(OptionPricingResult) -
name(str)
moneyness
¶
price
¶
Price a single option
This method will use the cache to get the maturity pricer if possible
| PARAMETER | DESCRIPTION |
|---|---|
option_type
|
Type of the option (call or put)
TYPE:
|
strike
|
Strike price of the option
TYPE:
|
forward
|
Forward price of the underlying
TYPE:
|
Source code in quantflow/options/pricer.py
prices
¶
Price a batch of call options with the same TTM and different log-strikes
Source code in quantflow/options/pricer.py
quantflow.options.pricer.ModelOptionPrice
pydantic-model
¶
Bases: BaseModel
Model price and sensitivities of an option for a given strike, forward and time to maturity.
The price field is always in forward space, regardless of whether the underlying market quotes options in the quote currency (e.g. SPX, USD) or in the underlying (inverse options, e.g. BTC).
Use price_in_quote to recover the quote-currency premium \(C = c\,F\).
Also exposes Black price and sensitivities for comparison.
Fields:
-
strike(DecimalNumber) -
option_type(OptionType) -
forward(DecimalNumber) -
log_strike(float) -
moneyness(float) -
ttm(float) -
price(float) -
delta(float) -
gamma(float)
price
pydantic-field
¶
Option price in forward space. Multiply by [forward][quantflow.options.pricer.ModelOptionPrice.price.forward] (or read [price_in_quote][quantflow.options.pricer.ModelOptionPrice.price.price_in_quote]) to obtain the quote-currency premium.
price_in_quote
property
¶
Premium in the quote currency: forward-space price times forward.
For inverse markets (BTC) the conventional premium is in the underlying and equals [price][quantflow.options.pricer.ModelOptionPrice.price_in_quote.price] directly; callers should pick the convention that matches their downstream consumer.
parity
property
¶
Put call parity value for the option, i.e. the difference between call and put price for the same strike and maturity
black
property
¶
Calculate the Black price for the option using the price as time value and log-strike
intrinsic_value
property
¶
Calculate the intrinsic value of the option in forward space for the given moneyness
This is the value of the option if it were to expire immediately, and it depends only on the moneyness and the type of the option.
For a call option, the intrinsic value is non-negative when the moneyness is negative, i.e. when the strike is below the forward price. For a put option, the intrinsic value is non-negative when the moneyness is positive, i.e. when the strike is above the forward price.
as_option_type
¶
Convert the option price to the given option type via put-call parity.
| PARAMETER | DESCRIPTION |
|---|---|
option_type
|
Type of the option, call or put
TYPE:
|