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/

    Optimization Exceptions on Windows 10 and Anaconda 3

    General Code/Help
    4
    9
    3778
    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.
    • P
      Praveen Baratam last edited by

      Exiting with the following error. Please help!

      ..Exception in thread Thread-3:
      Traceback (most recent call last):
        File "C:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
          self.run()
        File "C:\ProgramData\Anaconda3\lib\threading.py", line 864, in run
          self._target(*self._args, **self._kwargs)
        File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 429, in _handle_results
          task = get()
        File "C:\ProgramData\Anaconda3\lib\multiprocessing\connection.py", line 251, in recv
          return _ForkingPickler.loads(buf.getbuffer())
      TypeError: __init__() missing 9 required positional arguments: 'status', 'dt', 'barlen', 'size', 'price', 'value', 'pnl', 'pnlcomm', and 'tz'
      
      1 Reply Last reply Reply Quote 1
      • B
        backtrader administrators last edited by

        It's an error message. More cannot be said.

        1 Reply Last reply Reply Quote 0
        • C
          CptanPanic last edited by

          I am currently debugging a similar error in Linux, my current work around is to set maxcpus=1 when creating Cerebro()

          1 Reply Last reply Reply Quote 0
          • P
            Praveen Baratam last edited by

            @CptanPanic - I found that maxcpus=1 hack to override multiprocessing for timebeing.

            But without parallelism, python+backtrader is too slow for Optimization and Walkforward Analysis

            For instance, I am trying to replicate my strategies from another platform (C#) and it is atleast 20 times slower on python+backtrader without multiprocessing.

            1 Reply Last reply Reply Quote 0
            • P
              Praveen Baratam last edited by

              This is the error I am getting on Ubuntu with Python 2.7.. May be this can explain a but more ...

              Exception in thread Thread-3:
              Traceback (most recent call last):
                File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
                  self.run()
                File "/usr/lib/python2.7/threading.py", line 763, in run
                  self.__target(*self.__args, **self.__kwargs)
                File "/usr/lib/python2.7/multiprocessing/pool.py", line 380, in _handle_results
                  task = get()
              TypeError: ('__init__() takes exactly 10 arguments (2 given)', <class 'backtrader.trade.TradeHistory'>, ([['status', AutoOrderedDict([('status', 1), ('dt', 732713.9999999999), ('barlen', 0), ('size', -1800), ('price', 6120.873), ('value', 991581.426), ('pnl', 0.0), ('pnlcomm', 0.0), ('tz', None)])], ['event', AutoOrderedDict([('order', <backtrader.order.SellOrder object at 0x7f8c5de9c190>), ('size', -1800), ('price', 6120.873), ('commission', 1101.7571400000002)])]],))
              
              1 Reply Last reply Reply Quote 0
              • P
                Praveen Baratam last edited by

                I removed all dependencies related to tradehistory inside my strategies and then multiprocessing works as expected.

                1 Reply Last reply Reply Quote 1
                • C
                  CptanPanic last edited by

                  You are on to something. I currently had 3 analyzers, Calmar, Returns, and PyFolio. Multicore fails if I enable Calmar or Pyfolio. @backtrader Any ideas?

                  1 Reply Last reply Reply Quote 0
                  • P
                    Praveen Baratam last edited by

                    In the error trace I posted earlier, I saw the signature of TradeHistory so I tried to do away with it. Mine was an easy fix. Check your error traces and see if you can remove/fix something.

                    1 Reply Last reply Reply Quote 0
                    • André Tavares
                      André Tavares last edited by

                      Include the code in TradeHistory Class:

                      def __reduce__(self):
                          return (self.__class__, (self.status.status, self.status.dt, self.status.barlen, self.status.size,
                                                   self.status.price, self.status.value, self.status.pnl, self.status.pnlcomm,
                                                   self.status.tz,))
                      
                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors