df = alpaca.get_bars(
symbol=“AAPL”,
start=datetime. datetime(2013, 1, 12) - datetime.timedelta(days=10),
end=datetime. datetime(2013, 1, 12),
timeframe=TimeFrame.Minute,
adjustment=“raw”,
).df.between_time(“14:30”, “21:00”).tail(40)
$ python3 alpaca.py
Traceback (most recent call last):
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 234, in _one_request
resp.raise_for_status()
File “/home/jzyprince/.local/lib/python3.9/site-packages/requests/models.py”, line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://data.alpaca.markets/v2/stocks/AAPL/bars?timeframe=1Min&adjustment=raw&start=2013-01-02+00%3A00%3A00&end=2013-01-12+00%3A00%3A00
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/home/jzyprince/abc/examples/alpaca.py”, line 15, in
df = alpaca.get_bars(
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 714, in get_bars
bars = list(self.get_bars_iter(symbol,
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 698, in get_bars_iter
for bar in bars:
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 585, in _data_get
resp = self.data_get(path, data=data, feed=feed,
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 270, in data_get
return self._request(
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 213, in _request
return self._one_request(method, url, opts, retry)
File “/home/jzyprince/.local/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 242, in _one_request
raise APIError(error, http_error)
alpaca_trade_api.rest.APIError: invalid start