quantlab.factor.predefined.start_clipped.StartClippedFactor#
- class quantlab.factor.predefined.start_clipped.StartClippedFactor(config)[source]#
Bases:
FactorViewThe outputs of
config.factorfrom its store’s first bar on.read(start, end)reads the wrapped factor from the later ofstartand the first day of the wrapped factor’s recorded store range (store_range()), so the panel holds no bar before the store’s first; a read ending before that day returns the store’s variables and symbols on no bar.computeis clipped the same way, so a read and a computation return the same bars. A factor without a recorded store range is read and computed as asked. The end is never moved: the wrapped factor refuses a read past its store’s end. The store queries are a view’s (seeFactorView).- Parameters:
- configStartClippedConfig
The wrapped
factor.
Examples
With
hfa factor whose store holdscandm5from 2024-01-15 to 2024-02-09:>>> factor = StartClippedFactor(StartClippedConfig(factor=hf)) >>> panel = factor.read("2024-01-01", "2024-02-09") >>> str(panel["timestamp"].values[0])[:10] '2024-01-15' >>> factor.read("2024-01-01", "2024-01-08").sizes["timestamp"] 0
- compute(start, end)[source]#
Compute the wrapped factor from the later of
startand its store’s first bar toend.Examples
>>> str(factor.compute("2024-01-01", "2024-02-09")["timestamp"].values[0])[:10] '2024-01-15'
- config_cls#
The config class
from_configrebuilds this factor with.alias of
StartClippedConfig
- read(start, end, symbols=None)[source]#
Return the wrapped factor’s store from the later of
startand its first bar toend.- Parameters:
- start, endstr, datetime.date or pd.Timestamp
The range asked for, both inclusive.
- symbolssequence, optional
The symbols to read, among
stored_symbols();Nonereads them all.
- Raises:
- ValueError
If the wrapped factor’s
readrefuses the clipped request (for instanceendpast its store’s end).
Examples
>>> factor.read("2024-01-01", "2024-02-09").sizes["timestamp"] 20