Environment
Language
Python
Alpaca SDK Version
Version is 0.52.0
Problem
Summary
The times that .get_barset() is returning are not the respective times that we input. When we input timestamps for the start and end parameters we receive a response with a time that corresponds to a different date and time altogether.
Paper or Live Trading?
Currently not trading, just pulling historical data
Example Code
Input:
api = tradeapi.REST( alpacaApiKey, alpacaSecretKey )
startTime = str( datetime( 2021, 2, 2, 9, 30, 0 ).isoformat() )
endTime = str( datetime( 2021, 2, 2, 16, 0, 0 ).isoformat() )
print( startTime )
print( endTime )
price = api.get_barset( [“GOOG”], “5Min”, 126, startTime, endTime )
print( price )
Output:
2021-02-02T09:30:00
2021-02-02T16:00:00
{‘GOOG’: [Bar({ ‘c’: 2092.22, ‘h’: 2092.22, ‘l’: 2092.22, ‘o’: 2092.22, ‘t’: 1613139900, ‘v’: 269}), Bar({ ‘c’: 2088.05, ‘h’: 2091.67, ‘l’: 2086.38, ‘o’: 2088.82, ‘t’: 1613140200, ‘v’: 1659}), …]}
The t property (which should be epoch time in seconds, based on the documentation) in that first returned Bar object, t = 1613139900, corresponds to a date of Friday, February 12, 2021 8:25:00 AM GMT-06:00 (based on https://www.epochconverter.com/)