Skip to content
All library documents

Rolling Time-Series and Cross-Sectional Factor Utilities

Code Stratmill research code

Summary

This document describes helper calculations commonly used to construct quantitative signals from price or other tabular time series. Its functions cover rolling sums, averages, standard deviations, correlations, covariances, ranks, products, extrema, differences, and lagged values, alongside cross-sectional percentile ranking and rescaling. It also implements a linearly weighted moving average that gives more weight to recent observations.

The material is a code reference rather than a trading strategy and provides no performance evidence. Some implementation details constrain its reliability: the weighted-average functions fill missing values in place, one returns a fixed column label, and both rely on an older data-frame conversion interface. The notes also warn that a backtest must avoid look-ahead bias, but do not explain how to enforce that. Users should check the functions' behavior against their data shape, missing-value policy, and intended signal timing.

Key ideas

  • Rolling operators turn time series into window-based sums, averages, dispersion measures, associations, ranks, and extrema.
  • Lag and difference helpers provide basic ways to compare current observations with earlier values.
  • Cross-sectional ranking compares assets within each row, while scaling normalizes values by their absolute sum.
  • The weighted moving average assigns linearly increasing weights to more recent observations.
  • Missing-value filling and output-column handling can affect results and should be reviewed before use.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.