quantlab.dataset.massive.trade_bars#

The Trade bar panel built from Massive’s daily trade files, on the Massive ticker axis.

MassiveTradeBarDataset reads the raw tier the Massive client writes (quantlab.dataset.massive.raw) one trading day at a time, resamples the trades with quantlab.dataset.massive.resample.TradeBarResampler, and returns the dense (timestamp, symbol) panel the store holds (ADRs 0030, 0031).

  • Sessions are the XNYS calendar’s, half days included; the window is session_start to session_end, the regular session by default. A raw day that is not a session is refused.

  • The symbol axis is the Massive ticker, exactly as the trade files spell it (BRK.A, AApB), every ticker kept, exchange test symbols included (ADR 0031). Conversion reads no Sharadar data. A column is a ticker, not a security: one ticker can belong to different securities on different days, so reading the store as securities goes through the Ticker map (quantlab.dataset.massive.ticker_map). tickers restricts a conversion to a roster of Massive tickers.

  • A cell without an eligible trade has NaN prices and zero volumes and n_trades; a ticker on the axis that did not trade on a day is zero volume on every bar of it.

  • Per-day statistics (trades in, dropped by each rule, outside the session, excluded from volume, outside the roster) are written to the JSON sidecar <store>.massive_stats.json (stats_path), merged day by day.

  • Each one-minute day is checked against Massive’s own minute aggregates of that day when the raw tier holds them (quantlab.dataset.massive.vendor_check), ticker by ticker: agreement counts, the worst difference of each variable and the bars present on one side only go to the day’s vendor_check statistics. Differences are reported, never raised.

  • The store grows a day at a time. A config whose range holds the next day, passed to update(granularity="day"), appends that day: the day’s new tickers are appended at the end of the store’s axis in place (ADR 0032), with zero volume and NaN prices over the days before, so a backfill and a daily update are the same operation. Raw trade files are kept (ADR 0031).

  • The settings are the store’s identity. The bar interval, the session window, the roster and the counting rules (_build_settings) are recorded in the sidecar and in every read’s data fingerprint; a conversion into a store recorded with other settings is refused before anything is written. Each bar interval has its own store (trade_bar_store_name).

  • Coarser bars come from Resample. Each variable declares its aggregation (DEFAULT_RESAMPLE_HOW) and bars are cut per session, right closed and labelled at their end, so resample("5m") of the one-minute store equals converting the trades at 5m. "1d" gives one bar per session, labelled with its date.

Convert one day per window (granularity="day"): a day of the whole market is tens of millions of trades.

  • A day can be converted elsewhere. convert_day reads and resamples one day without touching the store, and returns a picklable ConvertedTradeDay; add_converted_day hands it to the instance that appends, which then does not read the day again. A backfill converts many days in worker processes this way and appends them in date order.

Examples#

Needs a trade file and a condition table under raw_data_dir_path:

config = MassiveTradeBarsDatasetConfig(
    zarr_file_path="/data/zarrs/massive_trade_bars_1m.zarr",
    raw_data_dir_path="/data/downloads/massive",
    start_date="2024-11-29",
    end_date="2024-11-29",
)
MassiveTradeBarDataset(config).from_raw_data_chunked(granularity="day")

Classes

ConvertedTradeDay

One converted trading day: its bars on the Massive ticker axis and its statistics.

MassiveTradeBarDataset

Dense Trade bar panel on the Massive ticker axis; see the module docstring.

Functions

no_trade_fills

Return the values of a Trade bar column without a trade: 0 volumes and counts.

trade_bar_store_name

Return the name of the Trade bar store of one bar interval.