@dan-yang said in Live feed inplace resampling:
I actually have the same issue, and I tested with the same code. It runs well for the history part (10 next) of the data, but fails right after that. Anybody has an idea?
import sys import backtrader as bt class TestStrategy(bt.Strategy): def notify_data(self, data, status, *args, **kwargs): print('*' * 5, 'DATA NOTIF:', data._getstatusname(status)) def next(self): msg = '***** NEXT: {} '.format(bt.num2date(self.data.datetime[0])) for d in self.datas: msg += '{} {} {} '.format(d._name, len(d), d.close[0]) print(msg) def run(argv): cerebro = bt.Cerebro() data = bt.feeds.CCXT(exchange='coinbasepro', symbol='BTC/USD', timeframe=bt.TimeFrame.Minutes, compression=1, ohlcv_limit=10) cerebro.adddata(data, name='1M') cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=2, name='2M') cerebro.addstrategy(TestStrategy) cerebro.run() if __name__ == '__main__': run(sys.argv)
here is the error
***** DATA NOTIF: LIVE ***** NEXT: 2018-06-27 06:34:00 1M 1 6084.04 2M 1 6084.04 ***** NEXT: 2018-06-27 06:35:00 1M 2 6084.05 2M 1 6084.04 ***** NEXT: 2018-06-27 06:36:00 1M 3 6084.05 2M 2 6084.05 ***** NEXT: 2018-06-27 06:37:00 1M 4 6084.05 2M 2 6084.05 ***** NEXT: 2018-06-27 06:38:00 1M 5 6084.04 2M 3 6084.04 ***** NEXT: 2018-06-27 06:39:00 1M 6 6080.75 2M 3 6084.04 ***** NEXT: 2018-06-27 06:40:00 1M 7 6080.74 2M 4 6080.74 ***** NEXT: 2018-06-27 06:41:00 1M 8 6080.74 2M 4 6080.74 ***** NEXT: 2018-06-27 06:42:00 1M 9 6080.75 2M 5 6080.75 ***** NEXT: 2018-06-27 06:43:00 1M 10 6080.74 2M 5 6080.75 ***** NEXT: 2018-06-27 06:44:00 1M 11 6080.75 2M 6 6080.75 ***** NEXT: 2018-06-27 06:45:00 1M 12 6080.75 2M 6 6080.75 Traceback (most recent call last): File "test.py", line 80, in <module> run(sys.argv) File "test.py", line 76, in run cerebro.run() File "c:\Anaconda3\lib\site-packages\backtrader-1.9.64.122-py3.6.egg\backtrader\cerebro.py", line 1127, in run File "c:\Anaconda3\lib\site-packages\backtrader-1.9.64.122-py3.6.egg\backtrader\cerebro.py", line 1298, in runstrategies File "c:\Anaconda3\lib\site-packages\backtrader-1.9.64.122-py3.6.egg\backtrader\cerebro.py", line 1557, in _runnext ValueError: min() arg is an empty sequence
Never mind, I found the issue is with my exchange 'coinbasepro'. It works well on other exchange like 'bitmex'. I will leave the post here just in case other people run into the same issue and can learn from my case.