data.loaders¶
Load a databento-data-playground Parquet export whose product, bar span and timestamp semantics ride in the file's own metadata.
loaders
¶
Load a databento-data-playground Parquet export into engine-ready bars.
The file is self-describing: the product, the bar span and which end of the
interval ts_event marks all live in its Parquet key-value metadata. They are
read from there rather than passed in, because the engine requires all of them
with no defaults and each is a silent corruption when guessed — the wrong
product scales P&L (an ES file run as MNQ is exactly 25x wrong), the wrong span
mis-stamps every bar against the session clock, and the wrong stamp shifts every
signal by one bar.
pandas and pyarrow are imported lazily — only load_bars needs them, and
both arrive with the [data] extra.
load_bars
¶
load_bars(path: str | Path) -> tuple[tuple[Bar, ...], InstrumentSpec, dict[str, Any]]
Read the export -> (bars, spec, metadata), ready for Backtest(...).
bars, spec, meta = load_bars("data/MNQ.ohlcv-1m.parquet")
Backtest(bars, MyStrategy(spec.symbol), account=AccountSize.S50K).run()
The returned contract id is the bare root ("MNQ"), matching what
stitch_continuous labels a continuous series with. meta is the
file's full embedded metadata blob (roll days, adjustment note,
provenance, ...), returned so callers can log or display it.