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

Optimization Exceptions on Windows 10 and Anaconda 3

  • Exiting with the following error. Please help!

    ..Exception in thread Thread-3:
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\", line 916, in _bootstrap_inner
      File "C:\ProgramData\Anaconda3\lib\", line 864, in run
        self._target(*self._args, **self._kwargs)
      File "C:\ProgramData\Anaconda3\lib\multiprocessing\", line 429, in _handle_results
        task = get()
      File "C:\ProgramData\Anaconda3\lib\multiprocessing\", 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'

  • administrators

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

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

  • @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.

  • 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/", line 810, in __bootstrap_inner
      File "/usr/lib/python2.7/", line 763, in run
        self.__target(*self.__args, **self.__kwargs)
      File "/usr/lib/python2.7/multiprocessing/", line 380, in _handle_results
        task = get()
    TypeError: ('__init__() takes exactly 10 arguments (2 given)', <class ''>, ([['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)])]],))

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

  • 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?

  • 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.

  • 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,

Log in to reply