I managed to get my optimizations to run as quick as optstrategy by subclassing Cerebro and pulling out some stuff out of run() and addstrategy() into different functions (one to initialize data loading, and another which gets re-executed from outside the class for optimization).
I also manage multiprocessing from the outside.
Do you mind to share some code? Or kind of a layout of what and where was implemented in more details?
in period duration (5Y)
out period duration (1Y)
parameters and ranges
Let's say we have 10 years worth of data, then the ideal processing would be as follows:
Break the data in multiple chunks according to the periods defined above
In Period 1: 2000-2005
Out Period 1: 2005-2006
In Period 2: 2001:2006
Out Period 2: 2006-2007
In Period 3: 2002-2007
Out Period 3: 2007-2008
Than start executiing the execution.
Optimize parameters for first In Period (2000-2005) - cerebro.optstrategy()
Get best parameters from previous run and test on Out Period 1 - cerebro.addstrategy()
Optimize again on the next In Period
Test with the parameters from previous step on the next out period
Optimize again ......
Test again on the next Out Period .....
At the end plot the combined strategy during all out periods from 2005 to 2010 by taking into consideration that parameters are being changed every year with the optimized values from last 5 years worth of data.
I am open for any ideas for implementation.
So far I am thinking to read the data in pandas, break it and loop through it in chunks and feed it to cerebro consecuently.
I have no idea how to combine the outputs from each cerebro run and how to plot all individual strategy executions into a single figure.