Successfully ran the strategy selection code in https://www.backtrader.com/blog/posts/2016-10-29-strategy-selection/strategy-selection/ (regardless of the value assigned to maxcpus
).
So, I extended the code to my needs.
In my code, when maxcpus
parameter in cerebro.run(maxcpus = ...)
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 cerebro.run(..)
has no effect on this error.
Should I change to another version of pickling/pickler?
> python stratsel.py
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/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/multiprocessing/pool.py", line 470, in _handle_results
task = get()
File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/multiprocessing/connection.py", 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/lineseries.py'>