Aggregating Live Bars into Multiple Minute Intervals in vn.py
Summary
The post describes modifying vn.py’s chart widget so incoming live bars can be combined into larger minute intervals. Its approach maps interval labels to minute counts, compares each incoming bar’s timestamp with the most recent stored bar, and, when the timestamps fall within the same target interval, updates the existing bar’s high, low, and accumulated volume while retaining its opening price and timestamp. It then rounds the timestamp down to the interval boundary and refreshes the chart.
The author presents this as a small change to the existing update method and says the approach supports several minute intervals, including hourly bars. The post does not provide test results or discuss exchange session boundaries, gaps, timezone handling, or how incoming bar data is expected to be structured. Those details matter when adapting the method: timestamp bucketing and aggregation behavior should be checked against the instrument’s trading calendar and the chart’s data conventions before relying on the resulting bars.
Key ideas
- The method combines incoming live bars into larger time-based chart bars.
- Within an interval, it preserves the first bar’s open and accumulates volume while updating the high and low.
- It assigns timestamps to interval boundaries before updating the chart display.
- The post describes support for several minute intervals, including hourly bars.
- Session boundaries, data gaps, and timestamp conventions are not discussed or tested in the document.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.