quantlab.backend.ranged#
A Zarr store written and read by date range: RangedStore.
A ranged store answers a request for a date range only inside the range it
was built for, which is recorded beside it in <store>.range.json.
build(start, end) replaces the store with the rows of the range and
records it, extend(end) appends the rows after the recorded range and
moves its end, rewind(end) drops the rows after an earlier end and moves
the end back, and a reader asks check_covers(start, end) before it opens
the store. Every row is computed by the compute function the store is
given, so a store built in one go and one built then extended are equal
whenever a row depends only on a bounded window of bars ending at its own.
A factor’s store (quantlab.factor.base.Factor) and a factor risk model’s
two stores (quantlab.risk.base.RiskStore) are written through one; each
supplies only its compute function, the name its messages give, and (a
factor) the rule refusing a write and the fill values of widened cells. How
a store is read (which variables and symbols, what is recorded) stays the
adapter’s.
Examples#
>>> store = RangedStore("rows.zarr", "Rows", compute) # compute(start, end) -> xr.Dataset
>>> store.build("2024-01-01", "2024-03-31")
>>> store.store_range()
('2024-01-01', '2024-03-31')
>>> store.extend("2024-04-30")
>>> store.store_range()
('2024-01-01', '2024-04-30')
Classes
A store written by date range, the range recorded beside it. |