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/

    problem when GenericCSVData uses fromdate,todate but no data in date range

    General Code/Help
    2
    2
    511
    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.
    • T
      Trade Prophet last edited by

      Hi,
      next () method seems to crash in a scenario when loading a data using GenericCSVData and there is no valid data in the csv file for the requested date range specified in fromdate,todate .
      in this case, the ticker is loaded with empty lines (since there is no OHLC data for the date range), and generates the below output:

        File "autotrader.py", line 80, in run
          cerebro.run(runonce=False)
        File "Python35\lib\site-packages\backtrader\cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
        File "Python35\lib\site-packages\backtrader\cerebro.py", line 1295, in runstrategies
          self._runnext(runstrats)
        File "Python35\lib\site-packages\backtrader\cerebro.py", line 1619, in _runnext
          self._brokernotify()
        File "Python35\lib\site-packages\backtrader\cerebro.py", line 1357, in _brokernotify
          self._broker.next()
        File "Python35\lib\site-packages\backtrader\brokers\bbroker.py", line 1230, in next
          self._get_value()  # update value
        File "Python35\lib\site-packages\backtrader\brokers\bbroker.py", line 446, in _get_value
          dvalue = comminfo.getvaluesize(position.size, data.close[0])
        File "Python35\lib\site-packages\backtrader\linebuffer.py", line 163, in __getitem__
          return self.array[self.idx + ago]
      IndexError: array index out of range
      

      Any advise ?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        @trade-prophet said in problem when GenericCSVData uses fromdate,todate but no data in date range:

        Any advise ?

        Yes. Use sensible data.

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