quantdata.ncde.voluvol.generate#
NCDE VoluVol data set generator#
This file contains then benchmark generator for the Volume & Volality benchmark.
- class quantdata.ncde.voluvol.generate.ExperimentScope(tickers=<factory>, date_range=DateRange(start=datetime.date(2025, 1, 1), end=datetime.date(2025, 1, 31), exclude_half_days=True), forecast_horizon_min=15)[source]#
Bases:
objectDefinition of the experiment
- quantdata.ncde.voluvol.generate.generate_ticker_day(ticker, d, forecast_horizon_min)[source]#
Generate an experiment entry for a given date
dfor a giventicker.Converts time stamps into milliseconds since market open.
Computes forward floating volume, cash volume and (annualized) volatilities as forecast “targets” for the horizon given by
forecast_horizon_min.Drops time stamps within
forecast_horizon_minbefore the close.
This function is cached with HDF5 for fast i/o. All data are return in 32 bit precision.
- Parameters:
ticker (
str) – Ticker symbol, e.g. “AAPL”date (
datetime.date) – Date for which to generate the data, e.g. date(2025, 1, 2)forecast_horizon_min (
int) – Rolling forecast horizon in minutes, e.g. 15
- Returns:
Results – A dictionary containing “trades”, “quotes”, and forward “targets” for the given ticker and date. The schema are:
quotes: “time_of_day_ms”, “bid_price”, “bid_size”, “ask_price”, “ask_size”
trades: “time_of_day_ms”, “price”, “size”
targets: “time_of_day_ms”, “log_volume”, “log_cash_volume”, “volatility”. The latter represent the future values from
time_of_day_mstotime_of_day_ms + forecast_horizon_min[ms].
The “time_of_day_ms” column represents the time in milliseconds since the market open, and is aligned across trades, quotes, and targets. The “targets” are forward looking values computed at each trade timestamp for the given forecast horizon.
The “time_of_day_ms” entries are returned as
int32while the other values are returned asfloat32for efficient storage and i/o.- Return type:
- class quantdata.ncde.voluvol.generate.SampleID(ticker, date)[source]#
Bases:
objectIdentifier for a sample, consisting of a ticker and a date.
- class quantdata.ncde.voluvol.generate.ExperimentLoader(experiment_scope, *, pool_config=<cdxcore.jcpool.JCPoolConfig object>, verbose=<cdxcore.verbose.Context object>)[source]#
Bases:
objectUtility class to load experiment data.
- property samples: dict[SampleID, dict[str, int]]#
Returns a dictionary of samples, indexed by
SampleID, each containing a dictionary with the counts oftrades,quotes, andtargets.
- get_sample_id(sample_id)[source]#
Return the
SampleIDfor a given sample id, typically for an integer index.
- get_sample(sample_id, *, cache_only=False)[source]#
Load the data for a given sample id. The data is returned as a dictionary containing “trades”, “quotes”, and “targets” for the given ticker and date. The schema are:
quotes: “time_of_day_ms”, “bid_price”, “bid_size”, “ask_price”, “ask_size”
trades: “time_of_day_ms”, “price”, “size”
targets: “time_of_day_ms”, “log_volume”, “log_cash_volume”, “volatility”. The latter represent the future values from
time_of_day_mstotime_of_day_ms + forecast_horizon_min[ms].
The “time_of_day_ms” column represents the time in milliseconds since the market open, and is aligned across trades, quotes, and targets. The “targets” are forward looking values computed at each trade timestamp for the given forecast horizon.
The “time_of_day_ms” entries are returned as
int32while the other values are returned asfloat32for efficient storage and i/o.