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\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'
    

  • 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/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)])]],))
    


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


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.