Multiple indicators example throws an error
jrhone opened this issue · 2 comments
jrhone commented
The multiple indicators example throws an error with the following config and real API keys
IS_BACKTEST = False
IS_LIVE = True
symbol = "AAPL"
$ python live_v3.py
2021-06-28 03:04:49,918 started trading stream
Traceback (most recent call last):
File "/Users/jonathanrhone1/Src/quant/live_v3.py", line 127, in <module>
cerebro.run()
File "/Users/jonathanrhone1/miniconda3/envs/quant39/lib/python3.9/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/Users/jonathanrhone1/miniconda3/envs/quant39/lib/python3.9/site-packages/backtrader/cerebro.py", line 1187, in runstrategies
self._broker.start()
File "/Users/jonathanrhone1/miniconda3/envs/quant39/lib/python3.9/site-packages/alpaca_backtrader_api/alpacabroker.py", line 103, in start
self.positions = self.update_positions()
File "/Users/jonathanrhone1/miniconda3/envs/quant39/lib/python3.9/site-packages/alpaca_backtrader_api/alpacabroker.py", line 83, in update_positions
broker_positions_symbols = [p.symbol for p in broker_positions]
File "/Users/jonathanrhone1/miniconda3/envs/quant39/lib/python3.9/site-packages/alpaca_backtrader_api/alpacabroker.py", line 83, in <listcomp>
broker_positions_symbols = [p.symbol for p in broker_positions]
File "/Users/jonathanrhone1/miniconda3/envs/quant39/lib/python3.9/site-packages/alpaca_trade_api/entity.py", line 29, in __getattr__
return super().__getattribute__(key)
AttributeError: 'Position' object has no attribute 'symbol'
$ pip freeze
alpaca-backtrader-api==0.14.0
alpaca-trade-api==1.2.2
backtrader==1.9.76.123
pandas==1.1.5
I also had to comment the Starting Portfolio Value
line.
brianhumphreys commented
Any workaround on this?
brianhumphreys commented
Make sure you are properly authenticated @jrhone. After some investigation, it seems that I was getting a 404 and the backtrader was trying to wrap the 404 response in a Position
object. Obviously, this was user error but perhaps there could be better error reporting around this @camelpac.
dependencies:
alpaca-backtrader-api==0.14.1
alpaca-trade-api==1.2.3