I should add, it is probably doing what it is supposed to be doing but the result is not what I desire. from the api call is it possible to only return last 6 databars before a specified time (say 14:59:00 PM)
I could do post processing after getting the data frame but ideally would like to fix it in the source so it is efficient.
I added _from=None as well and removed the time part in “to=” and nothing changed. if i remove to it gives post market data as well
I previously used api.get_barset previously and a lot of data was missing. And I found api.polygon.historic_agg to be more reliable on more granular data. So I am just looking to make api.polygon.historic_agg work which will return only last 6 barset before close.
get_barset works for stocks like “TSLA” and “AMZN” but data seems to be missing for small volume stocks. api.polygon.historic_agg works if i donot use the datetime filter in the query but I do need to somehow filter, may be i an using some wrong syntax?
I can’t believe this issue remains unaddressed. I spent a lot of time debugging to find these expected timestamps to be the culprit. Did you fix it by any chance? Much appreciated!
IDK if it helps I changed my timestamp when I saved the pandas Dataframe in a format that worked for me:
df.to_csv(path_or_buf=’./data/M_2019_12_06.csv’, date_format=’%Y-%m-%d %H:%M:%S’)
I went through the same crap and this allowed me to use the data in my backtest. Maybe you can change the format in some other way? I hope this helps