Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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.

    General Code/Help
    1
    1
    21
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Li Mike
      Li Mike last edited by

      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 sequence

      I 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.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors