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



  • 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 ?


  • administrators