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/

    Oanda and resampling

    General Code/Help
    2
    6
    116
    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.
    • leecallen
      leecallen last edited by

      Sorry folks but a second post with the same title - a related problem.

      I am sporadically getting this error:

      Traceback (most recent call last):
        File "anz48-notify.py", line 369, in <module>
          runstrategy( )
        File "anz48-notify.py", line 303, in runstrategy
          cycles = cerebro.run()
        File "/home/lallen/.local/lib/python3.6/site-packages/backtrader/cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
        File "/home/lallen/.local/lib/python3.6/site-packages/backtrader/cerebro.py", line 1298, in runstrategies
          self._runnext(runstrats)
        File "/home/lallen/.local/lib/python3.6/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
      

      I have seen this error reported a couple of times here, but in those cases the problem was determined to be the program was not identifying the timeframe in the underlying datafeed. But I am doing so:

      import btoandav20
      ...
          cerebro = bt.Cerebro()
          broker = BrokerCls( token='my token', account='my account', practice=False )
          cerebro.setbroker(broker)
          DataFactory = DataCls
          data = DataFactory( dataname='EUR_USD', timeframe=bt.TimeFrame.Minutes, compression=5 )
          cerebro.adddata(data)
          cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=60, rightedge=True)
          cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=180, rightedge=True)
         
          cerebro.addstrategy(TestStrategy)
          cycles = cerebro.run()
      

      The really weird part is, this is sporadic. The program runs fine for hours and then fails with this error. Or it runs fine on some currency pairs and fails on others.

      1 Reply Last reply Reply Quote 0
      • leecallen
        leecallen last edited by

        @leecallen said in Oanda and resampling:

        The really weird part is, this is sporadic. The program runs fine for hours and then fails with this error. Or it runs fine on some currency pairs and fails on others.

        Edit:

        The really weird part is, this is sporadic. The program runs fine for hours and then fails with this error. Or It runs fine on some currency pairs and fails on others.

        1 Reply Last reply Reply Quote 0
        • leecallen
          leecallen last edited by

          I need to edit that remark again. I am running 16 instances of my program against different forex currency pairs. Eventually all of them fail with this error. Most of them get through the backfill data and at least a few bars into live data before they fail.

          I could really use some advice on this, I can't figure out a workaround.

          1 Reply Last reply Reply Quote 0
          • vladisld
            vladisld last edited by

            This issue was discussed several times on this forum already - although no real fix was provided AFAIK - there were few hacks that 'fixed' the symptom though.

            Please see the following posts:

            https://community.backtrader.com/topic/26/example-of-adding-live-data-to-static-in-strategy (this is a long thread)
            https://community.backtrader.com/topic/2996/live-trading-data-ib-issue

            Not sure I fully understand the problem, but it looks like a bug to me. Will try to find a time to investigate it further.

            1 Reply Last reply Reply Quote 1
            • leecallen
              leecallen last edited by

              Thank you, I am going to try dasch's "ugly solution"

              1 Reply Last reply Reply Quote 0
              • leecallen
                leecallen last edited by

                @vladisld that change seems to be working fine for me. Thank you.

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