Don't get me wrong, I became already a big fan of backtrader. And big thanks to the author(s)! It's unbelievable how fast you could prototype ideas and I like the overall concepts and its simplicity! @run-out I totally see your point and will perform my own analysis. I've already pyfolio integrated and wanted to ensure, that I'm not reinventing something.
Thanks to @ab_trader I'm now able to perform optimizations on multiple assets by
- passing the names of the multiple DataFeeds to my strategy during optimization
- use a given DataFeed by setting it via self.data in my strategy
if self.params.data_name is not None:
self.data = self.getdatabyname(self.params.data_name)
This works fine so far!
At the moment I'm struggling with a Problem where the Analyzer seems to have Problems working on the given DataFeeds? I reset self.data there as well and even tried to pass self.data as first argument to the SMA.
params = ()
if self.strategy.params.data_name is not None:
self.data = self.strategy.getdatabyname(self.strategy.params.data_name)
self.ma_fast = btind.MovingAverageSimple(period=5, plotname='Analyzer MA fast')
but I'm getting an error, which comes from the SMA calculation:
Exception in thread Thread-3:
Traceback (most recent call last):
File "/home/trading/.pyenv/versions/3.5.9/lib/python3.5/threading.py", line 914, in _bootstrap_inner
File "/home/trading/.pyenv/versions/3.5.9/lib/python3.5/threading.py", line 862, in run
File "/home/trading/.pyenv/versions/3.5.9/lib/python3.5/multiprocessing/pool.py", line 463, in _handle_results
task = get()
File "/home/trading/.pyenv/versions/3.5.9/lib/python3.5/multiprocessing/connection.py", line 251, in recv
AttributeError: Can't get attribute 'AutoInfoClass_pl_LineSeries_pl_LineIterator_pl_DataAccessor_pl_ObserverBase_pl_Observer_pl_DataTrades_50b29187c1c944dfb72df69c6fbf3be2' on <module 'backtrader.metabase' from '/home/trading/.pyenv/versions/backtrader/lib/python3.5/site-packages/backtrader/metabase.py'>
The Problem also occours if I pass only one DataFeed via optstrategy.
Do you have any insights how to get the Analyzer also run with the different DataFeeds or just the DataFeed the according Strategy is using?