quantlab.factor.predefined.start_clipped.StartClippedFactor#

class quantlab.factor.predefined.start_clipped.StartClippedFactor(config)[source]#

Bases: FactorView

The outputs of config.factor from its store’s first bar on.

read(start, end) reads the wrapped factor from the later of start and 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. compute is 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 (see FactorView).

Parameters:
configStartClippedConfig

The wrapped factor.

Examples

With hf a factor whose store holds c and m5 from 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 start and its store’s first bar to end.

Examples

>>> str(factor.compute("2024-01-01", "2024-02-09")["timestamp"].values[0])[:10]
'2024-01-15'
config_cls#

The config class from_config rebuilds this factor with.

alias of StartClippedConfig

read(start, end, symbols=None)[source]#

Return the wrapped factor’s store from the later of start and its first bar to end.

Parameters:
start, endstr, datetime.date or pd.Timestamp

The range asked for, both inclusive.

symbolssequence, optional

The symbols to read, among stored_symbols(); None reads them all.

Raises:
ValueError

If the wrapped factor’s read refuses the clipped request (for instance end past its store’s end).

Examples

>>> factor.read("2024-01-01", "2024-02-09").sizes["timestamp"]
20