-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
is that bug? bt.optimize doesnt work for 0.6.2 and 0.6.3 #1244
-
there my code
import datetime
import pandas_ta as ta
import pandas as pd
import seaborn as sns
from backtesting import Backtest
from backtesting import Strategy
from backtesting.lib import crossover
from backtesting.test import GOOG
class RsiOscillator(Strategy):
upper_bound = 70
lower_bound = 30
rsi_window = 14
def init(self):
self.rsi = self.I(ta.rsi, pd.Series(self.data.Close), self.rsi_window)
def next(self):
if crossover(self.rsi, self.upper_bound):
self.position.close()
elif crossover(self.lower_bound, self.rsi):
self.buy()
bt = Backtest(GOOG, RsiOscillator, cash=10_000, commission=.002)
stats = bt.run()
stats, heatmap = bt.optimize(
upper_bound = range(50,85,5),
lower_bound = range(15,45,5),
rsi_window = range(10,30,2),
maximize='Equity Final [$]',
return_heatmap=True)
hm = heatmap.groupby(["upper_bound","lower_bound"]).mean().unstack()
sns.heatmap(hm, cmap="plasma")
plt.show()
here output for 0.6.1
here output for 0.6.2, 0.6.3 stucked on progress bar
Beta Was this translation helpful? Give feedback.
All reactions
No, my case is
@ 0.6.3
py file run without error
jpynb file run with #1242
Replies: 1 comment 5 replies
-
Likely a case of #1242. Please confirm.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
no, it doen't prompt any error , it just stucked at tqdm bar,
i leave it run for 1 hour, it still 0
python 3.12.9
bokeh.version: 3.6.3
win10
jupyter notebook
Beta Was this translation helpful? Give feedback.
All reactions
-
I have the 0.6.3 updated. I try to run "Multiple Time Frames" example python file then it works fine.
But when I try to run the jpynb. The same problem above happens.
I tried on 0.6.2, it is the same as 0.6.3.
When I restore to 0.6.1, both py and jpynb works fine !
It looks like when optimising the process doesn't fork !
Beta Was this translation helpful? Give feedback.
All reactions
-
according to webspiderc replied.
i run .py file. it show output same as #1242
i code it using jupter notebook, it show different output
Beta Was this translation helpful? Give feedback.
All reactions
-
No, my case is
@ 0.6.3
py file run without error
jpynb file run with #1242
Beta Was this translation helpful? Give feedback.
All reactions
-
webspiderc you right, may be jupyter notebook not compatible
Beta Was this translation helpful? Give feedback.