I am using the example https://medium.com/automation-generation/build-a-day-trading-algorithm-and-run-it-in-the-cloud-for-free-805450150668 and have followed all the instructions. When running I get the error:
Getting current ticker data…
Traceback (most recent call last):
File “algo.py”, line 396, in
run(get_tickers(), market_open, market_close)
File “algo.py”, line 49, in get_tickers
tickers = api.polygon.all_tickers()
File “/home/gferguson1815/.local/lib/python3.6/site-packages/alpaca_trade_api/polygon/rest.py”, line 212, in all_tickers
self.get(path, version=‘v2’)[‘tickers’]
File “/home/gferguson1815/.local/lib/python3.6/site-packages/alpaca_trade_api/polygon/rest.py”, line 35, in get
return self._request(‘GET’, path, params=params, version=version)
File “/home/gferguson1815/.local/lib/python3.6/site-packages/alpaca_trade_api/polygon/rest.py”, line 31, in _request
resp.raise_for_status()
File “/home/gferguson1815/.local/lib/python3.6/site-packages/requests/models.py”, line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.polygon.io/v2/snapshot/locale/us/markets/stocks/tickers?apiKey=XXXX
I have a Polygon account but in the above I am using the API key from the Alpaca dashboard for paper trading.
How do I resolve?