quantlab.factor.predefined.intraday.IntradayAverage#

class quantlab.factor.predefined.intraday.IntradayAverage(config)[source]#

Bases: Factor

The mean of each output of a stored factor over its last window bars.

Meant for a resampled IntradayStats: each daily statistic is averaged over the last window sessions, as the literature sorts stocks on them. The wrapped factor’s store is read (read), from window - 1 stored bars before start to end, so it must be built over the range first; nothing of the wrapped factor is computed. Missing values are skipped and a window with fewer than min_count present values is NaN; so are the first window - 1 bars of the store. Each output is named <output>_<window>d. The mean is a KunQuant graph.

Parameters:
configIntradayAverageConfig

The wrapped factor, window and min_count.

Raises:
ValueError

If warmup_bars is not 0, the config is resampled, window or min_count is not a positive integer or min_count exceeds window.

Examples

>>> monthly = IntradayAverage(IntradayAverageConfig(factor=daily, window=20))
>>> monthly.get_factor_names()[:2]
('rvol_20d', 'rskew_20d')
>>> monthly.compute("2024-03-01", "2024-03-29").sizes["timestamp"]
20
bar_after(date, n)[source]#

Return the bar n bars after date on the wrapped factor’s calendar.

See Factor.bar_after for the rules.

Examples

>>> monthly.bar_after("2024-03-01", 1) == daily.bar_after("2024-03-01", 1)
True
bar_before(date, n)[source]#

Return the bar n bars before date on the wrapped factor’s calendar.

See Factor.bar_before for the rules and errors.

Examples

>>> monthly.bar_before("2024-03-29", 1) == daily.bar_before("2024-03-29", 1)
True
calendar(start, end)[source]#

Return the wrapped factor’s bars from start to end, both inclusive.

The average is on the wrapped factor’s bars (the daily bars of a resampled IntradayStats), not on the minute bars of the dataset it holds; see Factor.calendar.

Examples

>>> monthly.calendar("2024-03-01", "2024-03-29").equals(daily.calendar("2024-03-01", "2024-03-29"))
True
compute(start, end)[source]#

Average the wrapped store from start to end, both inclusive.

Raises:
ValueError

If start is after end, the wrapped factor has no store or its store does not cover end.

Examples

>>> monthly.compute("2024-03-01", "2024-03-29")["rskew_20d"].sizes["timestamp"]
20
property config#

The factor’s normalised config: name and factor_names filled in.

Examples

>>> factor.config is config
False
>>> factor.config.name, config.name
('quantlab.factor.predefined.momentum.Momentum', None)
config_cls#

The config class from_config rebuilds this factor with.

alias of IntradayAverageConfig

output_symbols()[source]#

Return the wrapped factor’s output symbols.

Examples

>>> monthly.output_symbols() == daily.output_symbols()
True