5m Bar data are not resampled correctly


as you can see from the TQQQ price, the 5m bar does not have correct open, high, low, close prices.

@yann Perhaps the confusion is how bars are labeled. By convention, bars are always labeled by the start time. Therefore, the 5 minute bar labeled 9:35 will summarize the 5 bars from minutes 9:35-9.39.

Below shows how the data is resampled correctly.

Was that the issue?

1 Like

that makes sense. thanks!

hey, i was wondering how was the vwap calculated in the 1m bar? is it calculated the volume weighted price per bar? or is it using cumsum() which considers all the past bars? thanks! @Dan_Whitnable_Alpaca

@yann The vwap for a minute bar is calculated by first filtering for all the trades eligible for the volume calculation (which is virtually all trades). The price of each trade is multiplied by the size, or volume, of that trade. These are all summed to get a bar price-volume. That number is then divided by the volume to get the weighted vwap price.

For multi-minute bars, each minute bars vwap is multipled by the bars volume.These are all summed to get the multi-bar price-volume. That number is then divided by the sum of the volumes to get the weighted vwap price.

The vwap is therefore just the weighted average for that bar. It does not consider any past bars.