Skip to content
All library documents

Timestamp Grouping, Sampling Rates, and OHLCV Resampling Utilities

Code Stratmill research code

Summary

This small utility module provides basic operations for preparing timestamped market data. It estimates samples per day from the first observed interval, estimates elapsed days between the first and last timestamps, and partitions a dataframe into monthly, daily, or hourly groups. Its resampling routine groups observations by dynamic time windows and aggregates selected trading activity fields by summation, while carrying the last observed value for other columns.

These choices are useful for organizing intraday data and constructing coarser bars, but the code is implementation guidance rather than a trading strategy or empirical study. The sampling-rate estimate assumes the first interval represents the series; it only warns when intervals vary. The day count measures elapsed calendar time, not trading sessions. Resampling sums only columns with the specified trading-value, trading-volume, and trade-count names, so other additive fields would be treated as last-observation values unless adapted. Users should also ensure timestamps are ordered and that the chosen window boundaries fit their market’s session conventions.

Key ideas

  • The sampling-rate helper derives observations per day from the first timestamp interval.
  • A consistency check warns when the observed timestamp spacing varies.
  • The partition helpers group rows by calendar month, date, or hour.
  • Dynamic resampling sums designated trading activity columns and takes the final value for other columns.
  • Elapsed calendar days do not account for market holidays or session schedules.

Tags

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