quantdata.widb.options_filter#

Options Filter#

Provides daily option data subject to some filter and optional normalization.

class quantdata.widb.options_filter.OptionsFilter(normalize=True, max_num_options=1000, max_business_days_to_expiry=756, max_nms=(-5.0, 2.0), nms_use_atm=True, min_vegaSqrtVar=0.001, min_log_volume=1.0, min_log_open_interest=1.0, remove_am=False, min_opt_per_expiry=10)[source]#

Bases: object

Create a time series with a maximum number of valid options per time step.

..
    !! processed by numpydoc !!
normalize: bool = True#
max_num_options: int = 1000#

Maximum number of options. Options are sorted by NMS5, expiry and call/put, and only the top max_num_options are kept. This is applied after all other filters.#

..
    !! processed by numpydoc !!
max_business_days_to_expiry: int = 756#

Maximum business days to expiry.

..
    !! processed by numpydoc !!
max_nms: float | tuple[float, float] = (-5.0, 2.0)#

Maximum NMS5 or a tuple with NMS5_lower<0<NMS5_upper.

..
    !! processed by numpydoc !!
nms_use_atm: bool = True#

Whether to use NMS5 with the ATM volatility instead of the actual NMS5.

..
    !! processed by numpydoc !!
min_vegaSqrtVar: float = 0.001#

BSsq(K,sqrtVar) = BSvol(K,sqrtVar/sqrt(t),t). This is a measure of how much the option price moves with volatility, normalized by time to expiry.

:type: Minimum vega * sqrt(tte), i.e. the derivative in sqrtVar















..
    !! processed by numpydoc !!
min_log_volume: float = 1.0#

Minimum log volume.

..
    !! processed by numpydoc !!
min_log_open_interest: float = 1.0#

Minimum log open interest.

..
    !! processed by numpydoc !!
remove_am: bool = False#

Whether to remove options that settled at the AM price.

..
    !! processed by numpydoc !!
min_opt_per_expiry: int = 10#

Minimum number of options per expiry. This is applied before the max_num_options filter, and can lead to fewer than max_num_options being returned if there are many expiries with few options.

..
    !! processed by numpydoc !!
quantdata.widb.options_filter.normalize_day(ticker, d, df)[source]#

Create a normalized version of a day.

  • Drop spot

  • Add spot_ret: the return of the spot price compared to the previous day, i.e. spot / spot_prev - 1.

  • Divide the following fields by spot: spot_prev, call_ask, call_bid, fwd, strike, mkt_call_bid, mkt_put_bid, mkt_call_ask, mkt_put_ask.

quantdata.widb.options_filter.SCHEMA_OPTION_DAY(mk_arb_free, normalized)[source]#

Returns the schema for an option day series object depending on the MkArbFree configuration and whether it is normalized or not.

quantdata.widb.options_filter.filter_options_day(ticker, d, source_data=None, *, raw_day_filter=RawDayFilter(min_bid=0.011, drop_irregular_expiries=True), expiry_filter=ExpiryFilter(num_min_either_traded=10, num_min_both_traded=4, min_pure_spread=1e-06, min_implied_vol=0.01, max_implied_vol=5.0, normalize=False), mk_arb_free=MkArbFree(no_arb_mode='surface', smoothness=None, surface_expiry_linear=True, min_half_spread=0.0001, mid_fit_weight=0.1, min_atm_vol=0.05, min_dlv=None, max_dlv=None, timeout_seconds=300.0, min_strikes_per_expiry=5, min_density=0.0001, min_dC_eps=0.001, _debug_verbose_cvxpy=None, _remove_no_arb_strikes=True, _debug_super_dense=False, _eps_price=1e-06, _eps_density=1e-07, _eps_dens_1=0.0001, _eps_no_arb=0.01), options_filter=OptionsFilter(normalize=True, max_num_options=1000, max_business_days_to_expiry=756, max_nms=(-5.0, 2.0), nms_use_atm=True, min_vegaSqrtVar=0.001, min_log_volume=1.0, min_log_open_interest=1.0, remove_am=False, min_opt_per_expiry=10), raise_if_bad_day=True, override_cache_mode=None, cache_generate_only=False, verbose=<cdxcore.verbose.Context object>)[source]#

Filter options according to options_filter.

This includes filtering by moneyness, time to expiry, volume, open interest, and other criteria defined in OptionsFilter. This function itself is not cached, but it since it is basically a thin layer on top of mk_arb_free_day() and the filtering logic is fast, caching is implicit.