Thanks! This is just what I was searching for.
One question, why use an Analyzer class instead of the Strategy class?
Maybe there's something fundamental that I don't understand here..
I'm trying to implement a stock screener which scans 100 stocks and signals if the stock is in an oversold zone (using RSI). But it feels a little bit heavy to do it with backtrader.
So I'm wondering what's the best way to implement it?
Is backtrader a good library for this use case?
Yeah.. After the fix, the minute time frame has worked, but now I have trouble with the day time frame /:
When I'm trying to get the feed for the last 25 days, it gets stuck after just 12 days.
It could be that there are no history data for the other days but I don't think that it should hang.
hist_start_date = pandas.bdate_range(end=(datetime.datetime.now() - datetime.timedelta(days=25)), periods=1).to_pydatetime() data_days = bt.feeds.CCXT(exchange="gdax", symbol="BTC/USD", timeframe=bt.TimeFrame.Days, fromdate=hist_start_date)
It tries to fetch the ohlcv but it can't pass the 1512345600000 time stamp. In the end it returns from _fetch_ohlcv with no results, and then it seems to try to do it again (calls "_load" again) in an eternal loop.
About my last message - It seems that there was a bug in the ccxt feed, I fixed it and made a pull request
When I use the time frame of minutes, it just hangs and doesn't do anything -
hist_start_date = datetime.utcnow() - timedelta(minutes=30) data_min = bt.feeds.CCXT(exchange="gdax", symbol="BTC/USD", name="btc_usd_min", timeframe=bt.TimeFrame.Minutes, fromdate=hist_start_date) cerebro.adddata(data_min)
When I kill it, it seems to get stuck in some waiting routine -
Traceback (most recent call last): File "crypt-test.py", line 63, in <module> sys.exit(runstrategy(sys.argv)) File "crypt-test.py", line 60, in runstrategy cerebro.run() File "C:\Python27\lib\site-packages\backtrader\cerebro.py", line 1127, in run runstrat = self.runstrategies(iterstrat) File "C:\Python27\lib\site-packages\backtrader\cerebro.py", line 1295, in runstrategies self._runnext(runstrats) File "C:\Python27\lib\site-packages\backtrader\cerebro.py", line 1538, in _runnext drets.append(d.next(ticks=False)) File "C:\Python27\lib\site-packages\backtrader\feed.py", line 404, in next ret = self.load() File "C:\Python27\lib\site-packages\backtrader\feed.py", line 476, in load _loadret = self._load() File "C:\Python27\lib\site-packages\backtrader\feeds\ccxt.py", line 115, in _load self._fetch_ohlcv() File "C:\Python27\lib\site-packages\backtrader\feeds\ccxt.py", line 151, in _fetch_ohlcv sleep(self.exchange.rateLimit / 1000) # time.sleep wants seconds KeyboardInterrupt
Why does it sleep there?