Interpreting optimization results when using multiple strategies
vbs last edited by
I would like to integrate Bokeh plotting for optimization results but I have a problem interpreting optimization results when using multiple strategies.
Let's say I have this test code:
cerebro.optstrategy(TestStrategy, buydate=range(14, 16, 1)) cerebro.optstrategy(TestStrategy2, buydate=range(11, 13, 1)) cerebro.addanalyzer(bt.analyzers.TradeAnalyzer) data = ... cerebro.adddata(data) res = cerebro.run()
Now I have a list of 4 entries in the variable
res(all possible strategy combinations), which is fine for me. Each of these entities contain a list 2
OptReturnobjects. One for each strategy involved.
But how can I know which of these
OptReturnobjects belongs to which of the two strategies? I mean: I have 2
OptReturnobjects and I have 2 strategies. They only contain the set of optimization parameters and a list of analyzers.
They are returned in the same order in which they were inserted. You can also deactivate the return of the
OptReturnobjects and get the strategies by setting
vbs last edited by vbs
Thanks for quick answer.
So I would need to have access to strategy list which means I need a reference to the
cerebroobject to be able to process the
OptReturnobjects programmatically, right?
As far as I can see the plotting interface (which is called when trying to plot the
OptReturn) does not provide a reference to the the
cerebroobject in the call:
So my idea would be to pass a reference to the
cerebroobject (or maybe just to the strategy list) in the constructor call to my
Bokehplotting object (only needed when planning to plot optimization results with
optreturn=True). Then when plotting
cerebrocan be used to find the corresponding
Strategyobject and add, for example, the name of the strategy.
Does this sound reasonable or are there maybe better approaches to get the corresponding strategies?
Hm, another problem:
plotfunction is called for every
OptReturnobject seperately, so I don't know the current index in the list which I need to access the
So I would need to have access to strategy list
No. Your best bet is to use
Strategyinstances returned instead of
The plot function is called for every OptReturn object seperately, so I don't know the current index in the list which I need to access the Strategy list... hm..
This because if you are optimizing you can end up with hundreds or thousands of Strategy instances. Plotting was deemed to be meaningless. Hence the optimization in the returned values.
vbs last edited by
I agree that plotting is not useful when having a certain amount of outputs. I just thought it would make sense to implement it since
cerebroactually is trying to plot optimization results. However the integrated plotter seems to yield an exception when trying to plot opt results.
End users are (sometimes) also responsible for their actions, i.e.: trying to plot an optimization run.