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

Threading Error in

  • Successfully ran the strategy selection code in (regardless of the value assigned to maxcpus).

    So, I extended the code to my needs.

    In my code, when maxcpus parameter in = ...) is greater than 1, the error shown below would occur (it's a threading error). No errors occur when maxcpus = 1 and the run completes smoothly.

    Any idea as to what I should look at to find the source of the error?

    Changing the value of optreturn in has no effect on this error.

    Should I change to another version of pickling/pickler?

    > python
    Starting Portfolio Value: 1000.00
    Exception in thread Thread-3:
    Traceback (most recent call last):
      File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/", line 926, in _bootstrap_inner
      File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/", line 870, in run
        self._target(*self._args, **self._kwargs)
      File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/multiprocessing/", line 470, in _handle_results
        task = get()
      File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/multiprocessing/", line 251, in recv
        return _ForkingPickler.loads(buf.getbuffer())
    AttributeError: Can't get attribute 'Lines_LineSeries_LineIterator_DataAccessor_ObserverBase_Observer_DataTrades_7a5dc4c5b1604837b6655d447e5ae1e0' on <module 'backtrader.lineseries' from '/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/backtrader/'>

  • Please try to set the stdstats parameter to False:

    bt.Cerebro(maxcpus = ..., stdstats = False))

    This will disable the standard observers that are automatically added to your strategy by default. More here

    Also see the following posts:

  • @vladisld Thank you. Yes, the solution proposed resolved the error. I guess those facing this issue will have to manually add the observers they desire.

Log in to reply