I have all the values set for Live. Everything worked in Paper environment, but now the same code in Live is erroring:
I’m using a config.py to swap values between Live and Paper and I know I have them matching the api key, url, and secret from Live.
ValueError: (‘Key ID must be given to access Alpaca trade API’, ’ (env: APCA_API_KEY_ID)’)
- at get_credentials (/env/lib/python3.7/site-packages/alpaca_trade_api/common.py:76)
this error means you are not passing the key in any way (2 ways are possible: passing as arg to constructor or setting environment variable)
what is config.py? how is it used?
are you using the alpaca-trade-api package directly or through another package?
I found my issue. I had one function using the wrong api.REST call. It was picking up old values from environment variables instead of getting them from my config.py file, so I changed it to explicit api.REST call.
> api = tradeapi.REST()
> api = tradeapi.REST(config.APCA_API_KEY_ID, config.APCA_API_SECRET_KEY, base_url=config.APCA_API_BASE_URL)