quantdata.widb.timeseries#
Timeseries of daily data per ticker#
Sampling daily data into a time series using build_time_series().
This includes filtering and sampling the enriched day data for each day according to
the specified configuration, and optionally making the data arbitrage-free using mk_arb_free_day().
- class quantdata.widb.timeseries.TimeSeriesDefinition(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))[source]#
Bases:
objectUser-definition of a time series for experimentation.
- raw_day_filter: RawDayFilter = RawDayFilter(min_bid=0.011, drop_irregular_expiries=True)#
- expiry_filter: ExpiryFilter = 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)#
- options_filter: OptionsFilter = 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)#
- quantdata.widb.timeseries.build_time_series_uid(ticker, date_range, include_fields, exclude_fields, time_series_def)[source]#
Returns a relative UID for a time series based on its definition and the requested fields.
- quantdata.widb.timeseries.build_time_series(ticker, date_range, *, include_fields, exclude_fields, time_series_def, pool_config=<cdxcore.jcpool.JCPoolConfig object>, skip_bad_days=False, override_cache_mode=None, verbose=<cdxcore.verbose.Context object>)[source]#
Collect enriched data for a list of tickers and a date range.
This function collects daily data according to its
raw_day_filterfor the specified fields (which are usually defined by the target model).- Parameters:
ticker (str) – Ticker symbol, e.g. “SPX”
date_range (DateRange) – Date range for which to collect data. Only business days will be collected, and the date range can be configured to include or exclude half days.
include_fields (set[str] | None) – Fields to include. If
None, all fields are included by default.exclude_fields (set[str] | None) – Fields to exclude, if
include_fieldsisNone.time_series_def (TimeSeriesDefinition) –
Definition of the time series to be built, including the filters for data collection and sampling, Includes:
raw_day_filterofRawDayFilter:Configuration for data collection for the raw day data for basic data cleaning using
raw_collect_raw_day_day().
expiry_filterofExpiryFilter:Filter for expiries to be able to compute implied forwards. This will be passed to
enrich_day()for each day.
mk_arb_freeofMkArbFree| None:optional linear no-arbitrage filter which generates per expiry a no-arb
fit1between bid/ask, and for the entire surfacefitXwhich may not fit within bid/ask. This function also generates amask mask_arb_freefield indicating which options were fitted successfully (those which were not showed actionable static arbitrage on a given expiry).
options_filterofOptionsFilter:How many options to extract and how, every day using
filter_options_day().
pool_config (PoolConfig) – Configuration for parallel processing. By default, no parallel processing is used.
skip_bad_days (bool) – If
False, processing stops upon encountering an exception when creating the data for a given day. IfTrue, processing continues but building the time series will fail because of the missing date.override_cache_mode (CacheMode | None) – If not
None, overrides the cache mode for the enriched day data. Set to"update"to refresh the underlying raw cache.verbose (Context) – Verbose context for logging.
- Returns:
Time series – A dictionary with the requested fields, up to the maximum number of options specified in
options_filter, for each business day in the date range. The fields are returned as numpy arrays, and the date field is returned as a string in “YYYY-MM-DD” format The data is filtered and sampled according to the specified configurations.- Return type:
- quantdata.widb.timeseries.table_of_time_series(r)[source]#
Summarizes the sampled data from
build_time_series()in aprettytable.PrettyTablewhich can be displayed in a Jupyter notebook or printed in the console.The table includes the shape, dtype, size in bytes, mean, std, min and max for each field in the sampled data.