alpacahq/alpaca-backtrader-api

Encountering error using sample

Will-Copeland opened this issue · 1 comments

Hello,
Getting started with alpaca and backtrader, and while I can backtest just fine I am running into a weird error when trying to switch to live-paper mode.

Long story short, I ended up using the sample in this very repo, strategy_readme_sample to reduce mistakes I may have made.

The script has not been modified, save loading my credentials

Turns out the same issue happens. Once I run the script as-is, I get this error:

Script as-is output:

Starting Portfolio Value: 72948.0
Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/site-packages/alpaca_backtrader_api/alpacastore.py", line 723, in _t_streaming_prices
    method=method,
UnboundLocalError: local variable 'method' referenced before assignment

This seems to happen every time I try to paper trade with live data.

Is this because I do not have a funded account? My goal is to place "real" paper trades with my Alpaca paper account keys, and see them on my dashboard.

I have successfully placed trades using the Python Alpaca API SDK, without backtrader. I do not see why I would need a funded account between the two since the API is the same.

Any ideas?

Thanks in advance!

UPDATE

For anyone else experiencing this issue, using the strategy_multiple_indicators works!

I can see the trades happening in the Alpaca dashboard.

This doesn't resolve the issue, but I will keep digging and updating this thread.