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/

    Error at the end of backtesting if I use resampled data

    General Code/Help
    2
    4
    87
    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.
    • C
      CooleRnax last edited by

      When I resample '12H' data into '1D' data I get and error in the end of backtesting.

          results = cerebro.run()
        File "C:\ProgramData\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
        File "C:\ProgramData\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 1298, in runstrategies
          self._runnext(runstrats)
        File "C:\ProgramData\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 1557, in _runnext
          dt0 = min((d for i, d in enumerate(dts)
      ValueError: min() arg is an empty sequence
      
      1 Reply Last reply Reply Quote 0
      • C
        CooleRnax last edited by

        I don't understand what is the issue here. Please help!
        This is how I add data:

        GRANULARITY = {
            '1Min': [bt.TimeFrame.Minutes, 1],
            '5Min': [bt.TimeFrame.Minutes, 5],
            '30Min': [bt.TimeFrame.Minutes, 30],
            '1H': [bt.TimeFrame.Minutes, 60],
            '4H': [bt.TimeFrame.Minutes, 60 * 4],
            '12H': [bt.TimeFrame.Minutes, 60 * 12],
            '1D': [bt.TimeFrame.Days, 1],
        }
        
        data = bt.feeds.PandasData(
                    
                    	dataname=data_raw,
                    
                    	openinterest=None
                    
                    )
                    
                    
                    
                    cerebro.adddata(data, name=symbol + "_" + freqs[0])
                    
                    if len(freqs) > 1:
                    
                    	for freq in freqs[1:]:
                    
                    		name = symbol + "_" + freq
                    
                    		timeframe, compression = GRANULARITY[freq]
                    
                    		cerebro.resampledata(
                    
                    			data,
                    
                    			name=name,
                    
                    			timeframe=timeframe,
                    
                    			compression=compression,
                    
                    		)
        1 Reply Last reply Reply Quote 0
        • A
          ab_trader last edited by

          Seems you didn't set time frame and compression for baseline data. If I remember correctly bts default time frame is Daily. So you are re-sampling from days to intraday now.

          C 1 Reply Last reply Reply Quote 2
          • C
            CooleRnax @ab_trader last edited by

            @ab_trader said in Error at the end of backtesting if I use resampled data:

            Seems you didn't set time frame and compression for baseline data. If I remember correctly bts default time frame is Daily. So you are re-sampling from days to intraday now.

            Thanks! It worked!

                        timeframe, compression = GRANULARITY[freqs[0]]
                        data = bt.feeds.PandasData(
                            dataname=data_raw,
                            openinterest=None,
                            timeframe=timeframe,
                            compression=compression,
                        )
            
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
            $(document).ready(function () { app.coldLoad(); }); }