alpacahq / alpaca-backtrader-api

Alpaca Trading API integrated with backtrader
https://pypi.org/project/alpaca-backtrader-api/
Apache License 2.0
628 stars 147 forks source link

Minute data does not work #154

Open Acciorocketships opened 3 years ago

Acciorocketships commented 3 years ago

To reproduce this problem, simply go into one of the examples, set IS_BACKTEST=True, and change the timeframe to bt.TimeFrame.Minutes (instead of Days).

Exception in thread Thread-1: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/trading_calendars/utils/memoize.py", line 47, in get return self._cache[instance] File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/weakref.py", line 394, in getitem return self.data[ref(key)] KeyError: <weakref at 0x7f9010e07908; to 'XNYSExchangeCalendar' at 0x7f9010e057f0>

I also tried using Polygon data, but I ran into a different issue:

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.polygon.io/v2/...

Does anyone know how to solve this? It seems like this is a fundamental issue that should be affecting everyone.

If there is no way to solve it, is there at least a way to run with daily data at market open (instead of close)?

pitamonster commented 3 years ago

I can confirm that Alpaca minute data does exist/work, so maybe the surrounding code in the sample needs to get debugged and updated.

The Unauthorized response when attempting to access Polygon data might have to do with this https://forum.alpaca.markets/t/we-are-losing-polygon-data/4542.