Skip to content
All library documents

Finding the Volume on the Day of a Rolling-Window High

Article BigQuant

Summary

This tutorial explains how to retrieve one field’s value from the day another field reaches its maximum within a rolling window. Its example seeks the trading volume on the day of the highest price over the preceding 20 days. The approach uses `m_imax` to find the maximum’s position in the window, then `m_lag` to retrieve the desired field from that position.

The two functions count positions differently: `m_imax` returns an index starting at zero in window order, while `m_lag` expects the number of periods back from the current row. The tutorial converts between those conventions before using the lag function. It also illustrates the index behavior with a five-day opening-price example and dates from a Chinese stock. The material is a platform-specific calculation recipe; it does not evaluate a trading strategy, address tied maxima or missing data, or provide performance evidence.

Key ideas

  • The method uses a rolling maximum’s window index to identify the day of the extreme.
  • A conversion is needed because the maximum index and lag offset count positions in different directions.
  • A lag function can then retrieve another field, such as volume, from the maximum-price day.
  • The examples explain index behavior but do not test a strategy or discuss ties and missing observations.

Tags

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