For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
live trader error when resampling.
-
Hi, I am runing a live paper trade.
I accept ticks data and add it to cerebro, and resample to 10s bars in backtrader.
I get an error:
File "e:\myquant\venv_quant389\lib\site-packages\backtrader\cerebro.py", line 1591, in _runnext
dt0 = min((d for i, d in enumerate(dts) if d is not None and i not in rsonly))
ValueError: min() arg is an empty sequenceI did some debug and find that the problem comes from the following snippet.
In Cerebro's _runnext method, there is a snippet as follows.
if d0ret: dts = [] for i, ret in enumerate(drets): dts.append(datas[i].datetime[0] if ret else None) # Get index to minimum datetime if onlyresample or noresample: dt0 = min((d for d in dts if d is not None)) else: dt0 = min((d for i, d in enumerate(dts) if d is not None and i not in rsonly))
dt0 = min((d for i, d in enumerate(dts)
if d is not None and i not in rsonly))
this statement got 'min() arg is an empty sequence' error.
I think when sometime there is no tick, the err ocurs.How to fix this problem?
Thanks in advance.