I read this documentation.
Based on that article I tried to create a short python script that prints a list of all tradeable instruments on Alpaca.
Here is the code:
from alpaca_trade_api.rest import REST
api = REST()
assets = api.get('/v2/assets')
print(assets)
Here are the errors I am getting:
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
c:\Users\hello\Documents\projects\alpaca\main.ipynb Cell 2 in <cell line: 4>()
1 #get asset list
3 api = REST()
----> 4 assets = api.get('/v2/assets')
5 print(assets)
File c:\Users\hello\miniconda3\envs\alpaca\lib\site-packages\alpaca_trade_api\rest.py:250, in REST.get(self, path, data)
249 def get(self, path, data=None):
--> 250 return self._request('GET', path, data)
File c:\Users\hello\miniconda3\envs\alpaca\lib\site-packages\alpaca_trade_api\rest.py:213, in REST._request(self, method, path, data, base_url, api_version)
211 while retry >= 0:
212 try:
--> 213 return self._one_request(method, url, opts, retry)
214 except RetryException:
215 retry_wait = self._retry_wait
File c:\Users\hello\miniconda3\envs\alpaca\lib\site-packages\alpaca_trade_api\rest.py:234, in REST._one_request(self, method, url, opts, retry)
232 resp = self._session.request(method, url, **opts)
233 try:
--> 234 resp.raise_for_status()
235 except HTTPError as http_error:
236 # retry if we hit Rate Limit
...
1019 )
1021 if http_error_msg:
-> 1022 raise HTTPError(http_error_msg, response=self)
HTTPError: 404 Client Error: Not Found for url: https://api.alpaca.markets/v2/v2/assets
The article simply says:
This doesn’t seem very descriptive. What thought process should I have used to translate that information into a working python script?