api.get_bars()
import config
base_url = "https://paper-api.alpaca.markets"
import alpaca_trade_api as tradeapi
api = tradeapi.REST(config.API_KEY, config.SECRET_KEY, base_url=base_url, api_version='v2')
# api = tradeapi.REST()
symbol = 'AAPL'
symbol_bars = api.get_bars(symbol, 'minute', 1).df.iloc[0]
The last line returns.
Traceback (most recent call last):
File "/home/bwilson/DL/github.com/BruceRayWilson/MarketPrediction/src/bad_001.py", line 10, in <module>
symbol_bars = api.get_bars(symbol, 'minute', 1).df.iloc[0]
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 714, in get_bars
bars = list(self.get_bars_iter(symbol,
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 698, in get_bars_iter
for bar in bars:
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 585, in _data_get
resp = self.data_get(path, data=data, feed=feed,
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 270, in data_get
return self._request(
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 213, in _request
return self._one_request(method, url, opts, retry)
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 234, in _one_request
resp.raise_for_status()
File "/home/bwilson/dlvenv2/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://data.alpaca.markets/v2/stocks/AAPL/bars?timeframe=minute&adjustment=raw&start=1
Items related to my account work, e.g. open positions and available balance.
This example is essentially from the docs. I did change barset to bars due to a user comment.
What is wrong?