Hello! I am using Python to try to get the market data for yesterday, however it keeps returning an error. My code is
DATA_URL = "https://data.alpaca.markets/v2/stocks/{}/bars".format(symbol)
starttime = pd.Timestamp('2021-09-14 09:30', tz=pytz.timezone('America/New_York'))
endtime = pd.Timestamp('2021-09-14 10:30', tz=pytz.timezone('America/New_York'))
data = {
"start":starttime.isoformat(),
"end":endtime.isoformat(),
"timeframe": "1Min"
}
print(starttime.isoformat())
print(endtime.isoformat())
r = requests.get(DATA_URL, json=data, headers=HEADERS)
return_content = json.loads(r.content)
print(return_content)
where HEADERS is simply my api key and secret key, and work on other parts of my application. Whenever I run this, it prints
2021-09-14T09:30:00-04:00
2021-09-14T10:30:00-04:00
{‘code’: 42210000, ‘message’: ‘start can not be after end’}
When I swap the start and end, it gives me the exact same error. Any advice on how to solve this?