Expand description
Bar-aligned historical series for non-OHLCV streams.
The mlq backtester warmup is a slice factory: per (symbol, timeframe) it
drives each indicator bar-by-bar. To feed the ~130 non-OHLCV mli indicators
it needs, per (symbol, timeframe, stream), a series time-aligned to the
OHLCV bar grid — one value per bar — that warmup routes into the matching
mli update_* method. This module is dig3’s side of that contract: a fetch
that returns, for (exchange, account, symbol, kind, range), a bar-aligned
series pulled through the shared ExchangeHub REST surface.
Fill policy is decided by the nature of the stream, not a global flag
(see Kind::fill_policy):
- State streams (funding, OI, mark/index price, long/short ratio) are
levels → last-value carry-forward onto the bar grid. A bar with no
fresh observation carries the previous value (
filled = true). - Flow streams (liquidation, aggTrade) are event flows → bucket-sum
per bar, gaps are a real
0.0(filled = false).
Kline-family kinds (mark/index/premium price klines) arrive already on the
bar grid; they are returned verbatim as BarPoints, no resample needed.
Structs§
- Scalar
Bar - One bar’s worth of a scalar non-OHLCV stream, aligned to the OHLCV grid.
Enums§
- BarAligned
Series - Bar-aligned series, shaped by the stream kind. Mirrors the kline path so
mlq keys it the same way and warmup feeds it to the matching
update_*. - Fill
Policy - How a stream’s observations collapse onto a bar.
Functions§
- bar_
align_ from_ disk - Track-C read-path: read a recorded stream off its
DiskStoreand bar-align it in one call. Reads the lastmax_pointsrecords (the daemon appends forward-only, so the tail is the captured window), range-filters, and resamples perproject/policy. Native-only — the wasm OPFS store has a divergent read error type; wasm consumers read points then callbar_align_pointsdirectly. - bar_
align_ points - Bar-align an in-memory series of recorded [
DataPoint]s onto the OHLCV grid (Track C — daemon-recorded streams with no REST history: liquidations, L2, aggTrades). The forward-recording daemon (dig3 watch/ Station persistence) writes typed points to aDiskStore<T>; a consumer reads them back (DiskStore::read_tail/Series) and feeds the slice here with a scalar projection to get the same bar-aligned shape the REST loader produces. - load_
bar_ aligned - Load a bar-aligned historical series for one
(exchange, account, symbol, kind, interval)over[start_ms, end_ms). - load_
for_ key - Convenience wrapper keyed by
SeriesKey. The interval is read from the key’s kline-family kind; non-kline scalar kinds requireintervalto be passed viaload_bar_aligneddirectly (they carry no interval in the key).