Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

is that bug? bt.optimize doesnt work for 0.6.2 and 0.6.3 #1244

Answered by webspiderc
zonlee181 asked this question in Q&A
Discussion options

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

image

here output for 0.6.2, 0.6.3 stucked on progress bar

image

You must be logged in to vote

No, my case is
@ 0.6.3
py file run without error
jpynb file run with #1242

Replies: 1 comment 5 replies

Comment options

Likely a case of #1242. Please confirm.

You must be logged in to vote
5 replies
Comment options

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

Comment options

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 !

Comment options

according to webspiderc replied.
i run .py file. it show output same as #1242

i code it using jupter notebook, it show different output

Comment options

No, my case is
@ 0.6.3
py file run without error
jpynb file run with #1242

Answer selected by zonlee181
Comment options

webspiderc you right, may be jupyter notebook not compatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /