Skip to content
All library documents

Downsampling One-Minute Bars into Correct Five-Minute Bars

Article Quant Q&A · Author: user1514042

Summary

The document explains how to aggregate one-minute quote bars into five-minute bars. It identifies the operation as downsampling and clarifies the interval convention: a bar labeled 15:00 starts at that time and covers the minutes from 15:00 through 15:04. It therefore excludes the 15:05 one-minute bar, which belongs to the next five-minute interval.

For high and low values, the aggregated bar takes the minimum of the component lows and the maximum of the component highs within its interval. In the example, the 15:00 bar has a low of 7 and a high of 31, while the 15:05 bar has a low of 4 and a high of 25 based on the available data. That latter bar is incomplete until the remaining minutes in its interval are included. The guidance establishes interval boundaries and extrema aggregation for this example; it does not discuss other bar fields, missing minute records, or exchange-specific timestamp conventions.

Key ideas

  • Downsampling combines shorter-interval observations into longer-interval bars.
  • A bar label conventionally marks the start of the interval in the example.
  • The five-minute bar starting at 15:00 includes minutes 15:00 through 15:04.
  • The aggregated low and high are the minimum low and maximum high among included minute bars.
  • A bar cannot be treated as complete until all minutes in its interval are accounted for.

Tags

Full text
# Aggregating quotes data for different time frames


# Aggregating quotes data for different time frames












I need to aggregate data for a higher time frame. I have data for 1 min time frame as follows

```
Time   Min Max
15:00  9   31
15:01  7   19
15:02  7   19
15:03  8   17
15:04  8   22
15:05  4   25
```

and need producing data for 5 min frame. My approach is to take 5 previous records inclusively starting from `15:05` and calculate min/max withing that bucket, is that how they do it?

My Result for 5 min frame:

```
Time   Min Max
15:05  4    25
```

Can anyone confirm if this is the correct way of aggregating data?

## Answer by amdopt (score 4, accepted)

https://quant.stackexchange.com/a/49159

The actual term for this is downsampling. If you are trying to take 1-minute bar data and create 5-min bar data there are a few rules you should follow.

- The bar name is where it starts, not where it ends. The bar in your example should be called the 15:00 bar, not the 15:05 bar.

- It should not include the 15:05 1-minute bar. The bar should start at 15:00 and end at 15:04 (the 15:04 1-minute bar ends at 15:04:59).

The `min and max` in your example are 4 and 25. Your 15:00 bar should have a min and max of 7 and 31, respectively. Your 15:05 bar would currently have a min and max of 4 and 25, respectively, however, you need to add in the remaining 4 minutes to create that bar (bars 15:06 - 15:09).

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

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