For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

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 "", line 80, in run
      File "Python35\lib\site-packages\backtrader\", line 1127, in run
        runstrat = self.runstrategies(iterstrat)
      File "Python35\lib\site-packages\backtrader\", line 1295, in runstrategies
      File "Python35\lib\site-packages\backtrader\", line 1619, in _runnext
      File "Python35\lib\site-packages\backtrader\", line 1357, in _brokernotify
      File "Python35\lib\site-packages\backtrader\brokers\", line 1230, in next
        self._get_value()  # update value
      File "Python35\lib\site-packages\backtrader\brokers\", line 446, in _get_value
        dvalue = comminfo.getvaluesize(position.size, data.close[0])
      File "Python35\lib\site-packages\backtrader\", line 163, in __getitem__
        return self.array[self.idx + ago]
    IndexError: array index out of range

    Any advise ?

  • administrators

Log in to reply