alpaca-backtrader-api icon indicating copy to clipboard operation
alpaca-backtrader-api copied to clipboard

the readme example throws an Exception

Open jazzist91 opened this issue 3 years ago • 6 comments

I copied the example from the README exactly, I did not change anything except for modifying the API key , secret key and having the following setting:

IS_BACKTEST = True IS_LIVE = False symbol = "AAPL" ...

I am getting the following Exception:


Starting Portfolio Value: 100000.0
***** DATA NOTIF: DELAYED
xception in thread Thread-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/alpaca_backtrader_api/alpacastore.py", line 414, in _t_candles
    cdl = cdl.loc[
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 5162, in dropna
    raise KeyError(list(np.compress(check, subset)))
KeyError: ['high']

it seems that the data that is coming back from the Alpaca broker is not properly formatted please assist in resolving this

jazzist91 avatar Jun 22 '21 00:06 jazzist91

Hi have you installed the version?

camelpac avatar Jun 23 '21 18:06 camelpac

I checked all versions and made sure that they match the alpaca-backtrader-api reqruiements as far as I can tell, I have the most up to date code

jazzist91 avatar Jun 23 '21 22:06 jazzist91

I also see following error. Not sure which version of pandas work with alpaca

raise TypeError("Index must be DatetimeIndex")

hyeokhyen avatar Jun 25 '21 22:06 hyeokhyen

I'm seeing the same KeyError: ['high']

$ pip freeze 
alpaca-backtrader-api==0.14.0
alpaca-trade-api==1.2.2
backtrader==1.9.76.123
pandas==1.1.5

jrhone avatar Jun 28 '21 06:06 jrhone

I am also getting the same KeyError: ['high']

Name Version Build Channel

alpaca 1.0.0 pypi_0 pypi alpaca-backtrader-api 0.14.0 pypi_0 pypi alpaca-trade-api 1.2.2 pypi_0 pypi (dev)

PanicAtTheDisco88 avatar Jul 07 '21 13:07 PanicAtTheDisco88

{'code': 42210000, 'message': 'your subscription does not permit querying data from the past 15 minutes'}

update the data period to not include today:

data0 = DataFactory(dataname='AAPL', historical=True, fromdate=datetime(
        2019, 1, 1), todate=datetime(
        2021, 1, 1), timeframe=bt.TimeFrame.Days)
        

claytantor avatar Jul 20 '21 00:07 claytantor