-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
How to change the optimization input parameter range to include decimal values instead of just integers? #934
-
bt = Backtest(BackTestingData, SuperTrendPlus, cash=starting_cash,
commission=_commission, exclusive_orders=False, trade_on_close=True)
stats, heatmap = bt.optimize(ATR_Period=range(
10, 20, 2), InputMultuplier=range(4, 6, 1), method='grid', return_heatmap=True)
How to change the optimization input parameter range to include decimal values instead of just integers?like InputMultuplier=range(4, 6, 0.5)
Beta Was this translation helpful? Give feedback.
All reactions
The optimizer takes a list or similar type as arguments for the parameters to optimize over.
Therefore you can do something like this:
stats, heatmap = bt.optimize(ATR_Period=range(10, 20, 2), InputMultuplier=list(np.linspace(4, 6, 4)), method='grid', return_heatmap=True)
You can also just type out the list:
InputMultiplier=[4, 4.5, 5, 5.5, 6]
Or use numpy,arange which is similar to range (remember that we need to convert to list):
InputMultiplier=list(np.arange(4, 6, 0.5))
The optimizer may take an np.array type, but I'm not sure.
Replies: 1 comment 1 reply
-
The optimizer takes a list or similar type as arguments for the parameters to optimize over.
Therefore you can do something like this:
stats, heatmap = bt.optimize(ATR_Period=range(10, 20, 2), InputMultuplier=list(np.linspace(4, 6, 4)), method='grid', return_heatmap=True)
You can also just type out the list:
InputMultiplier=[4, 4.5, 5, 5.5, 6]
Or use numpy,arange which is similar to range (remember that we need to convert to list):
InputMultiplier=list(np.arange(4, 6, 0.5))
The optimizer may take an np.array type, but I'm not sure.
Beta Was this translation helpful? Give feedback.
All reactions
-
The optimizer may take an np.array type, but I'm not sure.
It might not currently, but I'm considering this to be a bug. 😅
Beta Was this translation helpful? Give feedback.