Noticed that get_prices handles timezones differently depending if you're querying history or realtime aggregate databases. This poses an issue when trying to use get_prices with both history and realtime databases at the same time; such as with live trading.
Examples:
# Getting prices from history database (the usstock minute bundle) gives prices up to 2:30PM EST
get_prices(["usstock-minute"], sids=['FIBBG00PN9XD40'], start_date="2021-05-21", end_date="2021-05-21 14:30:00", fields=["Close"])
# Getting prices from realtime aggregate database, with the same end date, only gives prices up to 10:30AM EST (basically timezone offset of -04:00 is being applied to an already offset time)
get_prices(["usstock-realtime-minute"], sids=['FIBBG00PN9XD40'], start_date="2021-05-21", end_date="2021-05-21 14:30:00", fields=["MinuteCloseClose"])
Tried specifying the timezone, but that had no effect. The only way I was able to get consistent responses when trying to get_prices from both these databases at the same time was by specify the end_date with the timezone offset applied. See below.
# Get history and realtime prices up to a specific time, with correct timezone applied
get_prices(["usstock-minute", "usstock-realtime-minute"], sids=['FIBBG00PN9XD40'], start_date="2021-05-21", end_date="2021-05-21T14:30:00-04:00", fields=["Close", "MinuteCloseClose"])
My specific problem occured when trying to run a backtest on pricing data from 2021-05-20 to 2021-05-21, and noticed that I wasn't getting any realtime pricing data back, only history data came through. The realtime data is being used to fill in pre and post market data onto the usstock-minute history prices, so basically I didn't get back any extended hours data. After troubleshooting I figured out the solution above, which was to specify an ISO-8601 end_date, with -04:00 offset, such as 2021-05-21T20:00:00-04:00
in order to get a correctly populated prices dataframe. While specifying an end-time sort of made sense, I was surprised to find that the -04:00 offset was required.
In short, I would expect the following to work to give me prices from both the history and realtime database through the end of 2021-05-21, without having to specify an end time, or a time with a specific timezone offset.
get_prices(["usstock-minute", "usstock-realtime-minute"], sids=['FIBBG00PN9XD40'], start_date="2021-05-21", end_date="2021-05-21", fields=["Close", "MinuteCloseClose"])
Any help/guidance is appreciated; thanks!