quantlab.dataset.nbbo.bars.NbboBarsDataset#
- class quantlab.dataset.nbbo.bars.NbboBarsDataset(dataset_config)[source]#
Bases:
NbboPanelBaseDense NBBO bar panel from bars the WRDS server resampled (
nbbo_bars).The raw tier is written by
quantlab.acquisition.wrds.taq_bars.WrdsTaqNbboBarsAcquisitionunder.../wrds/nbbo_bars/date=.../symbol=.../*.pqt: one row per(ticker, bar)with theSERVER_BAR_VARIABLES, labelled at the bar’s end. The panel is the oneNbboPanelDatasetbuilds from ticks: the same 13 variables, the same session grid, the PERMNO axis, the ticker and filter-stats sidecars and the cleaning, all inherited fromNbboPanelBase. This class only reads the bars, maps each raw(date, ticker)to its PERMNO and derivesmid,spread,spread_bpsandimbalancefrom the snapshot.Two differences from the tick path follow from the data being bars:
the session window and the filters were applied on the server, so the config must match the settings recorded with the download (
NbboBarsRequest), or the conversion refuses. The record is found in the watermark directory the acquisition writes beside the raw root,<raw root>/../_watermarks/<vendor>/nbbo_bars/, the layout every config factory andplace_downloadsproduce;the tick path merges the records of two raw tickers that resolve to one PERMNO on a date, but bars cannot be merged exactly, so such a date is refused, naming the tickers.
The server counts the records each filter dropped per
(date, ticker)and the acquisition keeps the counts on each ticker’s first bar; the conversion puts them on the PERMNO axis and merges them into the filter-stats sidecar, so the sidecar equals the tick path’s.- Parameters:
- dataset_configNbboBarsDatasetConfig
frequencyis the bar size and must be aBAR_INTERVAL_SECONDSkey;reference_dirholds the CRSP reference tables.
Examples
Needs a raw
nbbo_barstier and the CRSP reference tables:config = NbboBarsDatasetConfig( raw_data_dir_path="downloads/wrds", zarr_file_path="data/wrds_nbbo_server_1m.zarr", reference_dir="downloads/_reference", start_date="2024-01-24", end_date="2024-01-25", ) NbboBarsDataset(config).from_raw_data_chunked(granularity="day") panel = NbboBarsDataset(config).panel("2024-01-24", "2024-01-25") panel["bid"].dims # ('timestamp', 'symbol')
- DATA_TYPE = 'nbbo_bars'#
The data type whose directory under the vendor root holds the raw files.
- HIVE_SCHEMA = {'date': Date, 'symbol': String}#
The raw tier is laid out like the tick tier, one directory per
(date, ticker), whatever the bar size; the keys and their dtypes.
- config_cls#
The config class used to rebuild the dataset from a saved
config.json.alias of
NbboBarsDatasetConfig