Exception while optimizing
-
I am trying to optimize a strategy. It is working fine when I am using indicators such as AnnualReturn, Drawdown but whenever I use Sharpe or Sharpe_A, it throws the following exception and starts running endlessly.
Starting Portfolio Value: 100000.00 Exception in thread Thread-75: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python3.6/multiprocessing/pool.py", line 463, in _handle_results task = get() File "/usr/lib/python3.6/multiprocessing/connection.py", line 251, in recv return _ForkingPickler.loads(buf.getbuffer()) AttributeError: Can't get attribute 'Lines_LineSeries_LineIterator_DataAccessor_ObserverBase_Observer_DataTrades_a179e3eb9e354bd68d683450f934ee8a' on <module 'backtrader.lineseries' from '/usr/local/lib/python3.6/dist-packages/backtrader/lineseries.py'>
I think that this might be because of some deadlock due to multiprocessing. How can I correct this?
-
@zuj Please take a look at the following post:
https://community.backtrader.com/topic/3090/threading-error-in-cerebro-run-maxcpus/2and the links inside - this is a known issue with several possible solutions.
-
@vladisld Setting stdstats=False throws another error because some analyzer that is required uses this. The only way I am getting rid of the current error is by using maxcpus=1. So, there is no multithreading usage in my optimization which sucks. Can you please suggest any other way?
-
@zuj Setting the
maxcpus=1
is only a workaround. There is another link inside the link above suggesting the actual fix:https://community.backtrader.com/topic/2265/exception-when-running-optimize-with-optreturn-false/6