Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple indicators example throws an error #173

Open
jrhone opened this issue Jun 28, 2021 · 2 comments
Open

Multiple indicators example throws an error #173

jrhone opened this issue Jun 28, 2021 · 2 comments

Comments

@jrhone
Copy link

jrhone commented Jun 28, 2021

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
Copy link

Any workaround on this?

@brianhumphreys
Copy link

brianhumphreys commented Nov 7, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants