quantlab.dataset.nbbo.NbboPanelDataset#
- class quantlab.dataset.nbbo.NbboPanelDataset(dataset_config)[source]#
Bases:
NbboPanelBaseDense NBBO bar panel resampled from WRDS TAQ
complete_nbborecords.It inherits from
NbboPanelBaseeverything but the bars themselves: the session calendar, the PERMNO axis and its symbology, the sidecars, densifying and cleaning. Its_read_barsreads one window’s tick records and resamples them withNbboResampler.The
symbolaxis is the int64 PERMNO, built asNbboPanelBasedescribes. Each record’s raw ticker is replaced by its PERMNO before resampling, so the resampler groups quotes by security rather than by name.The session window (
session_start/session_end, US Eastern clock time) defaults to regular hours, 09:30 to 16:00, and may be set anywhere inside 04:00 to 20:00; an edge outside that range is refused when the dataset is created. On a half day only regular-hours edges are clipped to the early close, so an extended-hours window still runs to its clock end, and its bars after the close hold after-close quotes. Adate=directory that is not a trading session makes the conversion fail withValueError.Every window starts from the last valid quote at or before its start. The raw files are read by session date and hold the whole day, so the quote in force when the window opens is always available. Bar labels can fall outside the session date’s UTC calendar day: an extended close lands on the next one. The config’s filter fields (
drop_crossed,drop_locked,drop_nonpositive_price,keep_qu_cond) are passed to the resampler as anNbboFilterPolicy, and the number of quotes dropped per session is written to a JSON sidecar next to the store (seefilter_stats_path).Convert bars shorter than a minute with
granularity="day": one-second bars over a large universe are millions of rows per session, and one window is held in memory at a time.- Parameters:
- dataset_configNbboDatasetConfig
Must have
frequency="tick", abar_intervalfromBAR_INTERVAL_SECONDSand areference_dirholding the CRSP reference tables; also sets the session window, the quote filters and optionallypermnos.
- Attributes:
- last_filter_statsdict or None
The filter-stats sidecar content after the last window resampled.
Examples
Needs a raw NBBO tier on disk under the configured vendor root and the CRSP reference tables in
reference_dir:>>> config = NbboDatasetConfig( ... raw_data_dir_path="downloads/us_equity/tick/wrds_taq/wrds", ... zarr_file_path="data/us_equity/tick/wrds_nbbo_1m.zarr", ... reference_dir="downloads/_reference", ... start_date="2024-01-24", ... end_date="2024-01-25", ... bar_interval="1m", ... ) >>> NbboPanelDataset(config).from_raw_data_chunked(granularity="day") >>> panel = NbboPanelDataset(config).panel("2024-01-24", "2024-01-25") >>> panel["bid"].dims ('timestamp', 'symbol') >>> panel.symbol.values.tolist() [14593, 83443]
- DATA_TYPE = 'nbbo'#
The data type whose directory under the vendor root holds the raw files.