quantlab.factor.predefined.intraday#
High-frequency factors: daily statistics of each session’s one-minute bars.
IntradayStats reads one-minute bars (the Massive Trade bars, on the
permaticker axis) and computes, at every bar, a statistic of the session so
far: realized moments of the minute returns, their jump and semivariance
parts, the return of parts of the session, order imbalance, the
price-volume relation, the shape of the volume over the day and the share
of the closing auction. The value at a session’s last bar is the
statistic of the whole session, so resampled to "1d" with "last"
the factor is one value per stock and day:
daily = IntradayStats(config).resample("1d", "last")
IntradayAverage then averages the stored daily values over the last
window sessions, the form in which the literature sorts stocks on them
(a week in Amaya et al. 2015, a month in most of the rest).
Both are KunQuant graphs. KunQuant has no notion of a session, so
IntradayStats adds four inputs computed from the bar timestamps and
prices before the graph runs (_kunquant_inputs): the bar’s position in
its session and the bars left to its close, the last trade price at or
before the bar, and the reference price a bar’s return is measured from.
The session statistics are running sums that restart at each session’s
first bar (_session_sums), so a half day sums its own 210 bars and
nothing of the day before, and each bar costs the same whatever its
position in the session. A correlation’s second moments come from the same
running sums (sum xy - sum x sum y / n), the price taken from the
session’s first trade so its sums stay small in float32.
The minute return of bar t is log(p_t / p_{t-1}), p the last trade
price at or before a bar’s end within the session, carried over bars
without a trade (previous-tick sampling, so a bar without a trade returns
0). The first traded bar’s return is measured from its open, so the
session’s returns add up to log(last price / first trade) and the
overnight move is not one of them. The literature behind each output:
output |
definition, source |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
correlation of minute return and volume (Llorente, Michaely, Saar and Wang 2002, RFS) |
|
correlation of minute price and volume, the “price-volume divergence” factor of A-share broker research |
|
standard deviation over mean of minute volume |
|
share of the continuous volume in the last 30 bars |
|
closing-auction volume over the day’s volume (Bogousslavsky and Muravyev 2023, JFM) |
|
share of the volume reported through a TRF |
|
|
|
|
RV is sum r^2 and N the number of minute returns. A session with
fewer than min_returns bars with a trade gives NaN in every output.
Classes
One part of an |
|
The mean of each output of a stored factor over its last |
|
Equal-weight combinations of the cross-sectional ranks of trailing statistics of a stored factor. |
|
Parameters of |
|
Session statistics of one-minute bars, one value per bar for the session so far. |
Functions
Return the session inputs of |