Noob - calculating VWAP from bars data

Thanks for responding :slight_smile: I wondered if either the forum was dead, or if i’d asked such a stupid or offensive question that it wouldnt get answered.

I have looked through other’s code and seen things like bars[-1] to pull the last bar data, but this doesnt work when i try it. for example, something like:

for symbol in watchlist:
bars = api.get_barset(symbol,‘minute’,limit=10).df
bar = bars[-1]
print(bar)

i can print bars, but not bar.

As far as the calculation goes, its straightforward to roll up into different time increments in excel, but notice that the data has holes in it through the API when pulled as ‘minute’ (i.e. some minutes missing).

for example (NaN for the missing data at 15:56)

BYND
open high low close volume
time
2019-12-06 15:56:00-05:00 NaN NaN NaN NaN NaN
2019-12-06 15:57:00-05:00 76.235 76.27 76.210 76.210 1832.0
2019-12-06 15:58:00-05:00 76.220 76.25 76.190 76.200 1179.0
2019-12-06 15:59:00-05:00 76.215 76.25 76.205 76.205 10587.0

This defeats my simple logic in excel. :slight_smile:

If there is some sort of append command in python for adding vwap to each bar data, that would permit the real goal of comparing each bar to the vwap value.

Im gradually coming up to speed and expect to eventually understand any technical response, but feel free to include some explanation for the noob.

Cheers, Steve.