quantlab.core.store_uses#

Which stores a component uses: the one declaration and the one walk.

Every component declares the stores it uses itself, in Component.store_uses(): datasets, factors and factor risk models implement it, everything else declares none. A declaration lists only the component’s own direct uses; the stores of the components under it are theirs to declare. Each use is a StoreUse, a store path and one of three relations:

reads

the component’s panel, prediction or decision reads the store on a day (a leaf dataset’s store, a factor view’s wrapped store, a factor pinned to some variables of a store it does not own);

owns

the component writes the store by date range and can lengthen it, so the use carries the RangedStoreHandle that extends it (a factor’s store, a factor risk model’s regression and estimate stores);

source

the component’s store is written from it when it is built, but the store is not read on a day (the Trade bar store under the view a MappedTradeBarDataset writes its own store from).

A component marks a sub-component it only builds from with BuiltFrom: every use found under it is then a source use.

walk_store_uses is the one walk over a tree of components: it visits every sub-component (duck-typed on store_uses), takes each declaration, de-duplicates and orders the uses deepest first, owners first, the order in which ranged stores are extended (a risk model’s exposures factor before its regression store, that before its estimate store). Callers filter the result by relation: the live day checks the reads and extends the owns (quantlab.backtest.live), the data update reads all three (scripts/data_update/update.py).

Examples#

With label a Forward label over a factor that owns its store, over a dataset reading one store:

>>> [(use.where, use.relation) for use in walk_store_uses(label)]
[('factor.dataset', 'reads'), ('factor', 'owns')]

Classes

BuiltFrom

A sub-component the declaring component only builds its store from.

FoundStoreUse

One use walk_store_uses found: where, by whom, and the use.

RangedStoreHandle

What the live day and the data update ask of a store written by date range.

StoreUse

One store a component uses directly, and how.

Functions

walk_store_uses

Return every store use declared in the tree under root, root included.