trader.replay.bars_at module¶
The bars a prompt may see at a past instant.
The subtlety that makes this its own module: a 1d bar is stamped at exchange midnight, so the decision day’s own bar is timestamped 04:00Z — before a 14:00Z decision instant — while its close had not yet happened. A plain timestamp < as_of filter therefore leaks one day of the future, silently, on every row. The bound is the last session strictly before the decision day.
- trader.replay.bars_at.bars_before(repository, symbol, as_of, lookback, interval='1d')[source]¶
The last lookback bars closing strictly before as_of’s trading day.
Oldest first, because build_bar_summary slices the tail and renders in that order.
- Raises:
ReplayError – the repository returned a bar on or after as_of’s trading day. Asserted rather than filtered: a leak here is the scoring rule’s “silently invent skill” case, and the run must stop.
- Parameters:
repository (_BarRepo)
symbol (str)
as_of (datetime)
lookback (int)
interval (str)
- Return type:
list[Bar]