Optimisation with step sizes
Good Day All,
From what I've gathered from the documentation and from various examples online, it appears that the way to optimise strategy parameters is by using
Cerebro.optstrategy(Strategy, Param1 = range(1, 10)). My understanding is that by using the
Cerebro.optstrategy()method in the way mentioned above, backtrader will conduct backtest runs for each value within the range of parameter values with a step size of 1(1-9 for our example). If say I wanted to optimise my strategies using a step size of 2 instead, could I use
Cerebro.optstrategy(Strategy, Param1 = [1, 3, 5, 7, 9])instead?
range(1, 10)returns a list
[1, 2, 3, 4, 5, 6, 7, 8, 9], I technically should be able to use
Cerebro.optstrategy(Strategy, Param1 = [1, 3, 5, 7, 9])right? I just require confirmation that using the
Cerebro.optstrategy()method with a list wouldn't break backtrader
It takes probably 10 min to check in actual code, but lets take longer way.
From Docs - Cerebro - Reference -
optstrategy(strategy, *args, kwargs)
Adds a Strategy class to the mix for optimization. Instantiation will happen during run time. args and kwargs MUST BE iterables which hold the values to check.
[1, 3, 5, 7, 9]
seems an iterable, so should work.
run-out last edited by