quantlab.runs.live_predictions#

The live prediction store: a run’s predictions past its end, one bar at a time.

A backtest run’s prediction panel ends where the run ends. A strategy traded live needs the prediction of every new bar, made by the same model from the same stores; quantlab.backtest.live.predict_live_bar makes it, and this module holds the store it is appended to, so a reader (an executor that must not import model code) reads it with the run layer alone.

Layout. A Zarr store on (timestamp, symbol):

  • one float variable per label of the run’s prediction panel, named as the panel names it (ret_5), NaN where a symbol has no prediction (not an index member at the bar, or no features);

  • timestamp: the bars predicted, strictly increasing, one appended per call; symbol: the union of the symbols of every row, sorted (quantlab.utils.symbol_axis.sort_symbol_axis), widened when a row brings a new one (its earlier rows are NaN). Both index coordinates are kept in one chunk (XrBackend.append);

  • attrs: format_version and labels exactly as a prediction panel writes them (PredictionPanel), so PredictionPanel.read reads the store too, plus live_format_version (FORMAT_VERSION), run_dir (the backtest run directory, absolute), checkpoint (the checkpoint file the rows were predicted with, absolute) and trained_run (its trained unit’s directory).

Records. Beside the store, <store>.rows.json maps each bar’s label (bar_label: "2026-10-07" for a daily bar) to the record of the row: timestamp (ISO), written_at (UTC, ISO), run_dir, checkpoint, data_fingerprint (what the prediction read, by component path of the run’s backtester, as quantlab.runs.record.DataRecorder records it) and whatever else the writer adds (predict_live_bar adds stores, the stores it extended, and lagging). The row is appended first and its record written after it, so a crash between the two leaves a row without a record, never a record without a row.

Examples#

>>> store = LivePredictionStore("live/live_predictions.zarr")
>>> store.bars()[-1]
Timestamp('2026-10-07 00:00:00')
>>> row = store.row("2026-10-07")
>>> row["ret_5"].dims
('symbol',)
>>> store.record("2026-10-07")["checkpoint"]
'/data/quantlab/runs/sharadar_sp500/models/xgb_mvo/XGBoostRegressor_trial_0/model.joblib'

Classes

LivePredictionStore

An append-only store of one run's live predictions, one bar per append.