quantlab.factor.predefined.intraday.IntradayAverage#
- class quantlab.factor.predefined.intraday.IntradayAverage(config)[source]#
Bases:
FactorThe mean of each output of a stored factor over its last
windowbars.Meant for a resampled
IntradayStats: each daily statistic is averaged over the lastwindowsessions, as the literature sorts stocks on them. The wrapped factor’s store is read (read), fromwindow - 1stored bars beforestarttoend, 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 thanmin_countpresent values is NaN; so are the firstwindow - 1bars of the store. Each output is named<output>_<window>d. The mean is a KunQuant graph.- Parameters:
- configIntradayAverageConfig
The wrapped
factor,windowandmin_count.
- Raises:
- ValueError
If
warmup_barsis not 0, the config is resampled,windowormin_countis not a positive integer ormin_countexceedswindow.
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
nbars afterdateon the wrapped factor’s calendar.See
Factor.bar_afterfor 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
nbars beforedateon the wrapped factor’s calendar.See
Factor.bar_beforefor 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
starttoend, 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; seeFactor.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
starttoend, both inclusive.- Raises:
- ValueError
If
startis afterend, the wrapped factor has no store or its store does not coverend.
Examples
>>> monthly.compute("2024-03-01", "2024-03-29")["rskew_20d"].sizes["timestamp"] 20
- property config#
The factor’s normalised config:
nameandfactor_namesfilled in.Examples
>>> factor.config is config False >>> factor.config.name, config.name ('quantlab.factor.predefined.momentum.Momentum', None)
- config_cls#
The config class
from_configrebuilds this factor with.alias of
IntradayAverageConfig