Aggregating Daily Candles into Weekly OHLCV Bars
Summary
The document describes a helper routine for combining daily market records into weekly candles. The week boundary is configurable, with Sunday as the default start day. For each group of daily bars, the routine keeps the first open and timestamp, selects the highest high and lowest low, uses the final close, and adds the daily volumes to form weekly OHLCV data.
The example retrieves daily records from an exchange and returns null when data retrieval fails, an empty list when no records are available, or the aggregated weekly records otherwise. It illustrates a data-preparation technique useful when an exchange or analysis workflow needs weekly bars built from daily data. The document gives no trading strategy, validation, or edge-case discussion, so it does not establish how the aggregation behaves with missing dates, partial weeks, or unusual timestamp conventions.
Key ideas
- Daily bars can be grouped into weeks with a configurable start day.
- Each weekly candle uses the first daily open and the last daily close.
- Weekly highs and lows are the extrema across the grouped daily records.
- Daily volume is summed to produce weekly volume.
- The example handles retrieval failure and empty input, but does not discuss missing dates or partial weeks.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.