Vol Surface¶
quantflow.options.surface.VolSurface
pydantic-model
¶
Bases: BaseModel, Generic[S]
Represents a volatility surface, which captures the implied volatility of an option for different strikes and maturities.
Key Concepts:
- Implied Volatility: The market's expectation of future volatility, derived from the price of an option using a pricing model (e.g., Black-Scholes).
- Strike Price: The price at which the underlying asset can be bought (call option) or sold (put option) at the option's expiry.
- Time to Maturity: The time remaining until the option's expiration date.
- Volatility Smile/Skew: The often-observed phenomenon where implied volatility varies across different strike prices for the same maturity. Typically, it forms a "smile" or "skew" shape.
This class provides a structure for storing and manipulating volatility surface data. It can be used for various tasks, such as:
- Option pricing and risk management: Using the surface to determine the appropriate volatility input for pricing models.
- Volatility arbitrage: Identifying mispricings in options by comparing market prices to model prices derived from the surface.
- Market analysis: Understanding market sentiment and expectations of future volatility.
Fields:
-
ref_date(datetime) -
asset(str) -
spot(SpotPrice[S]) -
maturities(tuple[VolCrossSection[S], ...]) -
day_counter(DayCounter) -
tick_size_forwards(DecimalNumber | None) -
tick_size_options(DecimalNumber | None)
maturities
pydantic-field
¶
Sorted tuple of VolCrossSection, each containing the forward price and option prices for that maturity
day_counter
pydantic-field
¶
Day counter for time to maturity calculations, by default it uses Act/Act
tick_size_forwards
pydantic-field
¶
Tick size for rounding forward and spot prices - optional
tick_size_options
pydantic-field
¶
Tick size for rounding option prices - optional
securities
¶
securities(*, select=all, index=None, converged=False)
Iterator over securities in the volatility surface
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
converged
|
Include the spot, forwards and options with implied volatility converged only if True, otherwise include all securities regardless of convergence
TYPE:
|
Source code in quantflow/options/surface.py
inputs
¶
inputs(*, select=all, index=None, converged=False)
Convert the volatility surface to a VolSurfaceInputs instance
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
converged
|
Include spot, forwards and options with implied volatility converged only if True, otherwise include all securities regardless of convergence
TYPE:
|
Source code in quantflow/options/surface.py
term_structure
¶
Return the term structure of the volatility surface as a DataFrame
trim
¶
Create a new volatility surface with the last num_maturities maturities
option_prices
¶
option_prices(*, select=best, index=None, initial_vol=INITIAL_VOL, converged=False)
Iterator over selected option prices in the surface
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
converged
|
Include options with implied volatility converged only if True, otherwise include all options regardless of convergence
TYPE:
|
Source code in quantflow/options/surface.py
option_list
¶
option_list(*, select=best, index=None, converged=False)
List of selected option prices in the surface
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
converged
|
Include options with implied volatility converged only if True, otherwise include all options regardless of convergence
TYPE:
|
Source code in quantflow/options/surface.py
bs
¶
bs(*, select=best, index=None, initial_vol=INITIAL_VOL)
Calculate Black-Scholes implied volatility for options in the surface. For some option prices, the implied volatility calculation may not converge, in this case the implied volatility is not calculated correctly and the option is marked as not converged.
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
Source code in quantflow/options/surface.py
calc_bs_prices
¶
calc_bs_prices(*, select=best, index=None)
calculate Black-Scholes prices for all options in the surface
It uses options with a converged implied volatility calculation only, otherwise the price calculation won't be correct.
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
Source code in quantflow/options/surface.py
options_df
¶
options_df(*, select=best, index=None, initial_vol=INITIAL_VOL, converged=False)
Time frame of Black-Scholes call input data
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
converged
|
Whether the calculation has converged
TYPE:
|
Source code in quantflow/options/surface.py
as_array
¶
as_array(*, select=best, index=None, initial_vol=INITIAL_VOL, converged=False)
Organize option prices in a numpy arrays for Black volatility and price calculation
It returns an OptionArrays instance, which contains the option prices and their corresponding log strikes, time to maturity and implied volatility in numpy arrays for efficient calculations.
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
converged
|
If True, include only options for which the calculation has converged
TYPE:
|
Source code in quantflow/options/surface.py
reset_convergence
¶
Reset the convergence flag for all options in the surface
disable_outliers
¶
Disable outlier options across all maturities in the surface.
Calls VolCrossSection.disable_outliers on each maturity with the same parameters.
| PARAMETER | DESCRIPTION |
|---|---|
bid_ask_spread_fraction
|
Maximum allowed bid/ask spread as a fraction of the mid implied volatility. A value of 0.2 means options with a spread greater than 20% of the mid vol are disabled.
TYPE:
|
svi_residual_fraction
|
Maximum allowed SVI residual as a fraction of the mid implied volatility. A value of 0.2 means options whose mid vol deviates from the SVI fit by more than 20% of their mid vol are disabled.
TYPE:
|
repeat
|
Number of times to repeat the outlier removal process
TYPE:
|
Source code in quantflow/options/surface.py
plot
¶
plot(*, index=None, select=best, **kwargs)
Plot the volatility surface
| PARAMETER | DESCRIPTION |
|---|---|
index
|
Index of the cross section to use, if None use all
TYPE:
|
select
|
Option selection method
TYPE:
|
Source code in quantflow/options/surface.py
plot3d
¶
plot3d(*, select=best, index=None, dragmode='turntable', **kwargs)
Plot the volatility surface
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
index
|
Index of the cross section to use, if None use all
TYPE:
|
dragmode
|
Drag interaction mode for the 3D scene
TYPE:
|
Source code in quantflow/options/surface.py
quantflow.options.surface.VolCrossSection
pydantic-model
¶
Bases: BaseModel, Generic[S]
Represents a cross section of a volatility surface at a specific maturity.
Fields:
forward
pydantic-field
¶
Forward price of the underlying asset at the time of the cross section
day_counter
pydantic-field
¶
Day counter for time to maturity calculations - by default it uses Act/Act
ttm
¶
forward_rate
¶
Compute the implied continuous rate from spot and forward mid
Source code in quantflow/options/surface.py
forward_spread_fraction
¶
Bid-ask spread of the forward as a fraction of its mid price
info_dict
¶
Return a dictionary with information about the cross section
Source code in quantflow/options/surface.py
option_prices
¶
option_prices(ref_date, *, select=best, initial_vol=INITIAL_VOL, converged=False)
Iterator over option prices in the cross section
| PARAMETER | DESCRIPTION |
|---|---|
ref_date
|
Reference date for time to maturity calculation
TYPE:
|
select
|
Option selection method
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
converged
|
Whether the calculation has converged
TYPE:
|
Source code in quantflow/options/surface.py
securities
¶
securities(*, select=all, converged=False)
Iterator over all securities in the cross section
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
converged
|
Include the forward and options with implied volatility converged only if
TYPE:
|
Source code in quantflow/options/surface.py
option_securities
¶
option_securities(*, select=all, converged=False)
Iterator over all option securities in the cross section
| PARAMETER | DESCRIPTION |
|---|---|
select
|
Option selection method
TYPE:
|
converged
|
Include the forward and options with implied volatility converged only if
TYPE:
|
Source code in quantflow/options/surface.py
disable_outliers
¶
Disable outlier options in the cross section by marking them as not converged.
Two passes are applied:
First pass: options where the bid/ask spread in implied vol space exceeds
bid_ask_spread_fraction of the mid implied vol are disabled.
For example, a value of 0.2 disables options where the spread is more
than 20% of the mid vol. Options with a zero mid vol are also disabled.
Second pass: an SVI smile is fitted to the
surviving options (mid implied vol vs log-strike). Options whose
residual from the SVI fit exceeds svi_residual_fraction of their mid
implied vol are disabled. This is repeated up to repeat times,
refitting after each removal. The loop stops early if no outliers are
found or fewer than 5 options remain.
| PARAMETER | DESCRIPTION |
|---|---|
ttm
|
Time to maturity in years, used for SVI fitting
TYPE:
|
bid_ask_spread_fraction
|
Maximum allowed bid/ask spread as a fraction of the mid implied volatility. A value of 0.2 means options with a spread greater than 20% of the mid vol are disabled.
TYPE:
|
svi_residual_fraction
|
Maximum allowed SVI residual as a fraction of the mid implied volatility. A value of 0.2 means options whose mid vol deviates from the SVI fit by more than 20% of their mid vol are disabled.
TYPE:
|
repeat
|
Number of times to repeat the outlier removal process
TYPE:
|
Source code in quantflow/options/surface.py
quantflow.options.surface.GenericVolSurfaceLoader
pydantic-model
¶
Bases: BaseModel, Generic[S]
Helper class to build a volatility surface from a list of securities
Use this class to add spot, forward and option securities with their prices
and then call the surface method to build a VolSurface instance
from the provided data.
Fields:
-
asset(str) -
spot(SpotPrice[S] | None) -
maturities(dict[datetime, VolCrossSectionLoader[S]]) -
day_counter(DayCounter) -
tick_size_forwards(DecimalNumber | None) -
tick_size_options(DecimalNumber | None) -
exclude_open_interest(DecimalNumber | None) -
exclude_volume(DecimalNumber | None)
maturities
pydantic-field
¶
Dictionary of maturities and their corresponding cross section loaders
day_counter
pydantic-field
¶
Day counter for time to maturity calculations by default it uses Act/Act
tick_size_forwards
pydantic-field
¶
Tick size for rounding forward and spot prices - optional
tick_size_options
pydantic-field
¶
Tick size for rounding option prices - optional
exclude_open_interest
pydantic-field
¶
Exclude options with open interest at or below this value
exclude_volume
pydantic-field
¶
Exclude options with volume at or below this value
get_or_create_maturity
¶
Get or create a VolCrossSectionLoader for a given maturity
| PARAMETER | DESCRIPTION |
|---|---|
maturity
|
Maturity date for the options
TYPE:
|
Source code in quantflow/options/surface.py
add_spot
¶
Add a spot to the volatility surface loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the spot price
TYPE:
|
bid
|
Bid price for the spot
TYPE:
|
ask
|
Ask price for the spot
TYPE:
|
open_interest
|
Open interest for the spot
TYPE:
|
volume
|
Volume for the spot
TYPE:
|
Source code in quantflow/options/surface.py
add_forward
¶
Add a forward to the volatility surface loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the forward price
TYPE:
|
maturity
|
Maturity date for the forward price
TYPE:
|
bid
|
Bid price for the forward
TYPE:
|
ask
|
Ask price for the forward
TYPE:
|
open_interest
|
Open interest for the forward
TYPE:
|
volume
|
Volume for the forward
TYPE:
|
Source code in quantflow/options/surface.py
add_option
¶
add_option(security, strike, maturity, option_type, bid=ZERO, ask=ZERO, open_interest=ZERO, volume=ZERO, inverse=True)
Add an option to the volatility surface loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the option
TYPE:
|
strike
|
Strike price for the option
TYPE:
|
maturity
|
Maturity date for the option
TYPE:
|
option_type
|
Type of the option (call or put)
TYPE:
|
bid
|
Bid price for the option
TYPE:
|
ask
|
Ask price for the option
TYPE:
|
open_interest
|
Open interest for the option
TYPE:
|
volume
|
Volume for the option
TYPE:
|
inverse
|
Whether the option is an inverse option
TYPE:
|
Source code in quantflow/options/surface.py
surface
¶
Build a volatility surface from the provided data
| PARAMETER | DESCRIPTION |
|---|---|
ref_date
|
Reference date for the volatility surface
TYPE:
|
Source code in quantflow/options/surface.py
quantflow.options.surface.VolSurfaceLoader
pydantic-model
¶
Bases: GenericVolSurfaceLoader[DefaultVolSecurity]
Helper class to build a volatility surface from a list of securities
Use this class to add spot, forward and option securities with their prices
and then call the surface method to build a VolSurface instance
from the provided data.
Fields:
-
asset(str) -
spot(SpotPrice[S] | None) -
maturities(dict[datetime, VolCrossSectionLoader[S]]) -
day_counter(DayCounter) -
tick_size_forwards(DecimalNumber | None) -
tick_size_options(DecimalNumber | None) -
exclude_open_interest(DecimalNumber | None) -
exclude_volume(DecimalNumber | None)
maturities
pydantic-field
¶
Dictionary of maturities and their corresponding cross section loaders
day_counter
pydantic-field
¶
Day counter for time to maturity calculations by default it uses Act/Act
tick_size_forwards
pydantic-field
¶
Tick size for rounding forward and spot prices - optional
tick_size_options
pydantic-field
¶
Tick size for rounding option prices - optional
exclude_open_interest
pydantic-field
¶
Exclude options with open interest at or below this value
exclude_volume
pydantic-field
¶
Exclude options with volume at or below this value
add
¶
Add a volatility security input to the loader
| PARAMETER | DESCRIPTION |
|---|---|
input
|
Volatility surface input data
TYPE:
|
Source code in quantflow/options/surface.py
get_or_create_maturity
¶
Get or create a VolCrossSectionLoader for a given maturity
| PARAMETER | DESCRIPTION |
|---|---|
maturity
|
Maturity date for the options
TYPE:
|
Source code in quantflow/options/surface.py
add_spot
¶
Add a spot to the volatility surface loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the spot price
TYPE:
|
bid
|
Bid price for the spot
TYPE:
|
ask
|
Ask price for the spot
TYPE:
|
open_interest
|
Open interest for the spot
TYPE:
|
volume
|
Volume for the spot
TYPE:
|
Source code in quantflow/options/surface.py
add_forward
¶
Add a forward to the volatility surface loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the forward price
TYPE:
|
maturity
|
Maturity date for the forward price
TYPE:
|
bid
|
Bid price for the forward
TYPE:
|
ask
|
Ask price for the forward
TYPE:
|
open_interest
|
Open interest for the forward
TYPE:
|
volume
|
Volume for the forward
TYPE:
|
Source code in quantflow/options/surface.py
add_option
¶
add_option(security, strike, maturity, option_type, bid=ZERO, ask=ZERO, open_interest=ZERO, volume=ZERO, inverse=True)
Add an option to the volatility surface loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the option
TYPE:
|
strike
|
Strike price for the option
TYPE:
|
maturity
|
Maturity date for the option
TYPE:
|
option_type
|
Type of the option (call or put)
TYPE:
|
bid
|
Bid price for the option
TYPE:
|
ask
|
Ask price for the option
TYPE:
|
open_interest
|
Open interest for the option
TYPE:
|
volume
|
Volume for the option
TYPE:
|
inverse
|
Whether the option is an inverse option
TYPE:
|
Source code in quantflow/options/surface.py
surface
¶
Build a volatility surface from the provided data
| PARAMETER | DESCRIPTION |
|---|---|
ref_date
|
Reference date for the volatility surface
TYPE:
|
Source code in quantflow/options/surface.py
quantflow.options.surface.VolCrossSectionLoader
pydantic-model
¶
Bases: BaseModel, Generic[S]
Fields:
-
maturity(datetime) -
forward(FwdPrice[S] | None) -
strikes(dict[Decimal, Strike[S]]) -
day_counter(DayCounter)
forward
pydantic-field
¶
Forward price of the underlying asset at the time of the cross section
day_counter
pydantic-field
¶
Day counter for time to maturity calculations - by default it uses Act/Act
add_option
¶
add_option(security, strike, option_type, bid=ZERO, ask=ZERO, open_interest=ZERO, volume=ZERO, inverse=True)
Add an option to the cross section loader
| PARAMETER | DESCRIPTION |
|---|---|
security
|
Security for the option
TYPE:
|
strike
|
Strike price for the option
TYPE:
|
option_type
|
Type of the option (call or put)
TYPE:
|
bid
|
Bid price for the option
TYPE:
|
ask
|
Ask price for the option
TYPE:
|
open_interest
|
Open interest for the option
TYPE:
|
volume
|
Volume for the option
TYPE:
|
inverse
|
Whether the option is an inverse option
TYPE:
|
Source code in quantflow/options/surface.py
cross_section
¶
| PARAMETER | DESCRIPTION |
|---|---|
ref_date
|
Reference date for the volatility surface
TYPE:
|
previous_forward
|
Previous forward price for the volatility surface Usaed by the implied forward calculation to replace missing or unreliable forwards
TYPE:
|
tick_size
|
Tick size for rounding implied forward bid/ask prices
TYPE:
|
Source code in quantflow/options/surface.py
Bid/Ask Prices¶
quantflow.options.surface.Price
pydantic-model
¶
Bases: BaseModel, Generic[S]
Represents the bid/ask price of a security, which can be a spot price, forward price or option price
Fields:
-
security(S) -
bid(DecimalNumber) -
ask(DecimalNumber)
bp_spread
property
¶
Bid-ask spread in basis points, calculated as spread divided by mid price and multiplied by 10000
quantflow.options.surface.SpotPrice
pydantic-model
¶
Bases: Price[S]
Represents the spot bid/ask price of an underlying asset
Fields:
-
security(S) -
bid(DecimalNumber) -
ask(DecimalNumber) -
open_interest(DecimalNumber) -
volume(DecimalNumber)
bp_spread
property
¶
Bid-ask spread in basis points, calculated as spread divided by mid price and multiplied by 10000
quantflow.options.surface.FwdPrice
pydantic-model
¶
Bases: Price[S]
Represents the forward bid/ask price of an underlying asset at a specific maturity
Fields:
-
security(S) -
bid(DecimalNumber) -
ask(DecimalNumber) -
maturity(datetime) -
open_interest(DecimalNumber) -
volume(DecimalNumber)
quantflow.options.surface.ImpliedFwdPrice
pydantic-model
¶
Bases: FwdPrice[S]
Represents the implied forward price of an underlying asset at a specific maturity, extracted from option prices via put-call parity
Fields:
-
security(S) -
bid(DecimalNumber) -
ask(DecimalNumber) -
maturity(datetime) -
open_interest(DecimalNumber) -
volume(DecimalNumber) -
strike(DecimalNumber)
bp_spread
property
¶
Bid-ask spread in basis points, calculated as spread divided by mid price and multiplied by 10000
moneyness
¶
aggregate
classmethod
¶
Aggregate implied forward prices extracted from put-call parity into a single best-estimate forward price.
Selection: valid implied forwards are sorted by bid-ask spread in basis points and the tightest 5 are retained as candidates. Let \(c\) denote the tightest bp spread among the candidates.
Default priority: if a default forward is provided and its bp spread is tighter than \(c\), it is returned immediately as the most reliable price.
Default inclusion: if the default's bp spread is wider than \(c\) but narrower than the worst candidate, it is appended to the candidate pool and weighted on equal footing with the implied forwards.
Weighting: each candidate \(i\) receives weight
where the spread weight is a Gaussian on the normalised distance from the
best spread \(c\) and the proximity weight, applied only when
previous_forward is provided.
The result is the weighted average of the candidate mid prices, with the
bid/ask spread computed as the weighted average of candidate spreads.
When tick_size is provided the output bid is rounded down and the ask
is rounded up to the nearest tick.
| PARAMETER | DESCRIPTION |
|---|---|
implied_forwards
|
Implied forward prices from put-call parity
TYPE:
|
ttm
|
Time to maturity in years
TYPE:
|
default
|
Market forward (e.g. from futures) used as fallback or for blending
TYPE:
|
previous_forward
|
Anchor forward for proximity weighting, typically the previous maturity
TYPE:
|
tick_size
|
Tick size for rounding the implied forward bid/ask
TYPE:
|
Source code in quantflow/options/surface.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
inputs
¶
is_valid
¶
Check if the forward price is valid, which means that the bid and ask are positive and the bid is less than or equal to the ask
quantflow.options.surface.Strike
pydantic-model
¶
Bases: BaseModel, Generic[S]
Option prices for a single strike
Fields:
-
strike(DecimalNumber) -
call(OptionPrices[S] | None) -
put(OptionPrices[S] | None)
implied_forward
¶
Extract the implied forward price from put-call parity.
Requires both a call and a put at this strike. Uses bid/ask prices
to construct the bid/ask of the implied forward. When tick_size is
provided, bid is rounded down and ask is rounded up to the nearest tick.
For inverse options (prices quoted in the underlying currency) put-call parity reads
For non-inverse options (prices quoted in the quote currency)
Returns None when the strike does not have both a call and a put, or when the denominator is non-positive (arbitrage condition violated).
| PARAMETER | DESCRIPTION |
|---|---|
tick_size
|
Tick size for rounding the implied forward bid/ask
TYPE:
|
Source code in quantflow/options/surface.py
options_iter
¶
options_iter(forward, *, select=all)
Iterator over option prices for the strike
It uses the select parameter to determine which options to include in
the iteration. The forward price is used to determine the moneyness of
the options when the best selection method is used, in which
case only the Out of the Money options are included in the iteration.
| PARAMETER | DESCRIPTION |
|---|---|
forward
|
Forward price of the underlying asset
TYPE:
|
select
|
Option selection method
TYPE:
|
Source code in quantflow/options/surface.py
securities
¶
securities(forward, *, select=all, converged=False)
Iterator over option prices for the strike
| PARAMETER | DESCRIPTION |
|---|---|
forward
|
Forward price of the underlying asset
TYPE:
|
select
|
Option selection method
TYPE:
|
converged
|
Include options with implied volatility converged only if True, otherwise include all options regardless of convergence
TYPE:
|
Source code in quantflow/options/surface.py
option_prices
¶
option_prices(forward, ttm, *, select=best, initial_vol=INITIAL_VOL, converged=False)
| PARAMETER | DESCRIPTION |
|---|---|
forward
|
Forward price of the underlying asset
TYPE:
|
ttm
|
Time to maturity in years
TYPE:
|
select
|
Option selection method
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
converged
|
Include options with implied volatility converged only if True, otherwise include all options regardless of convergence
TYPE:
|
Source code in quantflow/options/surface.py
quantflow.options.surface.OptionArrays
¶
Bases: NamedTuple
Represents the option data in array form for efficient calculations via vectorized operations
log_strike
instance-attribute
¶
The log strike of the options, calculated as log(strike/forward)
quantflow.options.surface.OptionMetadata
pydantic-model
¶
Bases: BaseModel
Represents the metadata of an option, including its strike, type, maturity, and other relevant information.
Fields:
-
strike(DecimalNumber) -
option_type(OptionType) -
maturity(datetime) -
forward(DecimalNumber) -
ttm(float) -
open_interest(DecimalNumber) -
volume(DecimalNumber) -
inverse(bool)
quantflow.options.surface.OptionPrice
pydantic-model
¶
Bases: BaseModel
Represents the price of an option quoted in the market along with its metadata and implied volatility information.
Fields:
-
price(DecimalNumber) -
meta(OptionMetadata) -
implied_vol(float) -
side(Side) -
converged(bool)
price_in_forward_space
property
¶
Price of the option as a percentage of the forward price
price_bp
property
¶
Price of the option in basis points, calculated as price in forward space multiplied by 10000
price_intrinsic
property
¶
Intrinsic price of the option in forward space, which is the price if the option had zero time value
price_time
property
¶
Time value of the option in forward space, which is the price minus its intrinsic value
call_price
property
¶
call price in forward space
use put-call parity to calculate the call price if a put
put_price
property
¶
put price in forward space
use put-call parity to calculate the put price if a call
create
classmethod
¶
create(strike, *, price=ZERO, implied_vol=INITIAL_VOL, forward=None, ref_date=None, maturity=None, day_counter=None, option_type=call, open_interest=ZERO, volume=ZERO, inverse=True)
Create an option price
mainly used for testing
Source code in quantflow/options/surface.py
is_in_the_money
¶
calculate_price
¶
Source code in quantflow/options/surface.py
info_dict
¶
Source code in quantflow/options/surface.py
quantflow.options.surface.OptionPrices
pydantic-model
¶
Bases: BaseModel, Generic[S]
Represents the market for a single option contract (identified by its strike, maturity and option type), holding the bid and ask sides as separate OptionPrice objects.
Fields:
-
security(S) -
meta(OptionMetadata) -
bid(OptionPrice) -
ask(OptionPrice)
converged
property
¶
Check if the implied volatility calculation has converged for both bid and ask
iv_bid_ask_spread
¶
iv_mid
¶
is_in_the_money
¶
disable
¶
prices
¶
Iterator over bid/ask option prices
| PARAMETER | DESCRIPTION |
|---|---|
forward
|
Forward price of the underlying asset
TYPE:
|
ttm
|
Time to maturity in years
TYPE:
|
initial_vol
|
Initial volatility for the root finding algorithm
TYPE:
|
Source code in quantflow/options/surface.py
inputs
¶
Convert the option prices to an OptionInput instance
Source code in quantflow/options/surface.py
quantflow.options.surface.OptionSelection
¶
Bases: Enum
Option selection method
This enum is used to select which one between calls and puts are used for calculating implied volatility and other operations
quantflow.options.surface.surface_from_inputs
¶
Helper function to build a volatility surface from a VolSurfaceInputs instance
| PARAMETER | DESCRIPTION |
|---|---|
inputs
|
Volatility surface input data
TYPE:
|
Source code in quantflow/options/surface.py
Vol Surface Inputs¶
quantflow.options.inputs.VolSurfaceInputs
pydantic-model
¶
Bases: BaseModel
Class representing the inputs for a volatility surface
Fields:
-
asset(str) -
ref_date(datetime) -
inputs(list[ForwardInput | SpotInput | OptionInput])
quantflow.options.inputs.VolSurfaceInput
pydantic-model
¶
Bases: BaseModel
Base class for volatility surface inputs
Fields:
quantflow.options.inputs.SpotInput
pydantic-model
¶
Bases: VolSurfaceInput
Input data for a spot contract in the volatility surface
Fields:
-
bid(DecimalNumber) -
ask(DecimalNumber) -
open_interest(DecimalNumber) -
volume(DecimalNumber) -
security_type(VolSecurityType)
quantflow.options.inputs.ForwardInput
pydantic-model
¶
Bases: VolSurfaceInput
Input data for a forward contract in the volatility surface
Fields:
-
bid(DecimalNumber) -
ask(DecimalNumber) -
open_interest(DecimalNumber) -
volume(DecimalNumber) -
maturity(datetime) -
security_type(VolSecurityType)
quantflow.options.inputs.OptionInput
pydantic-model
¶
Bases: VolSurfaceInput
Input data for an option in the volatility surface
Fields:
-
bid(DecimalNumber) -
ask(DecimalNumber) -
open_interest(DecimalNumber) -
volume(DecimalNumber) -
strike(DecimalNumber) -
maturity(datetime) -
option_type(OptionType) -
security_type(VolSecurityType) -
iv_bid(DecimalNumber | None) -
iv_ask(DecimalNumber | None) -
inverse(bool)
iv_bid
pydantic-field
¶
Implied volatility based on the bid price as decimal number (e.g. 0.2 for 20%)
iv_ask
pydantic-field
¶
Implied volatility based on the ask price as decimal number (e.g. 0.2 for 20%)
inverse
pydantic-field
¶
Whether the security is inverse (i.e. quoted in terms of the underlying) or not (i.e. quoted in terms of the quote currency)