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/

    Exception while optimizing

    General Code/Help
    2
    4
    128
    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.
    • Z
      zuj last edited by

      I am trying to optimize a strategy. It is working fine when I am using indicators such as AnnualReturn, Drawdown but whenever I use Sharpe or Sharpe_A, it throws the following exception and starts running endlessly.

      Starting Portfolio Value: 100000.00
      Exception in thread Thread-75:
      Traceback (most recent call last):
        File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
          self.run()
        File "/usr/lib/python3.6/threading.py", line 864, in run
          self._target(*self._args, **self._kwargs)
        File "/usr/lib/python3.6/multiprocessing/pool.py", line 463, in _handle_results
          task = get()
        File "/usr/lib/python3.6/multiprocessing/connection.py", line 251, in recv
          return _ForkingPickler.loads(buf.getbuffer())
      AttributeError: Can't get attribute 'Lines_LineSeries_LineIterator_DataAccessor_ObserverBase_Observer_DataTrades_a179e3eb9e354bd68d683450f934ee8a' on <module 'backtrader.lineseries' from '/usr/local/lib/python3.6/dist-packages/backtrader/lineseries.py'>
      

      I think that this might be because of some deadlock due to multiprocessing. How can I correct this?

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

        @zuj Please take a look at the following post:
        https://community.backtrader.com/topic/3090/threading-error-in-cerebro-run-maxcpus/2

        and the links inside - this is a known issue with several possible solutions.

        Z 1 Reply Last reply Reply Quote 1
        • Z
          zuj @vladisld last edited by

          @vladisld Setting stdstats=False throws another error because some analyzer that is required uses this. The only way I am getting rid of the current error is by using maxcpus=1. So, there is no multithreading usage in my optimization which sucks. Can you please suggest any other way?

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

            @zuj Setting the maxcpus=1 is only a workaround. There is another link inside the link above suggesting the actual fix:

            https://community.backtrader.com/topic/2265/exception-when-running-optimize-with-optreturn-false/6

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