Comments (9)
try pip install bokeh==3.3.0.dev2
from backtesting.py.
Hey, im getting the same error;(
bokeh 3.3.0 didn't work for me.
Are there any solutions?
from backtesting.py.
Expected Behavior
Using a backtest instance to plot (calling the plot() function) the graphs of the performance of the strategy.
Actual Behavior
I installed the Backtesting framework and ran a simple strategy but when I call plot() on a backtest instance I get a TypeError because of Bokeh
TypeError Traceback (most recent call last) d:\CMU-A\Notebooks\FQAAT\Assignment 3\Bollinger Bands.ipynb Cell 35 line 1 ----> 1 backtest.plot()
File c:\Users\Gaella\anaconda3\envs\general\Lib\site-packages\backtesting\backtesting.py:1592, in Backtest.plot(self, results, filename, plot_width, plot_equity, plot_return, plot_pl, plot_volume, plot_drawdown, smooth_equity, relative_equity, superimpose, resample, reverse_indicators, show_legend, open_browser) 1589 raise RuntimeError('First issue
backtest.run()
to obtain results.') 1590 results = self._results -> 1592 return plot( 1593 results=results, 1594 df=self._data, 1595 indicators=results._strategy._indicators, 1596 filename=filename, 1597 plot_width=plot_width, 1598 plot_equity=plot_equity, 1599 plot_return=plot_return, 1600 plot_pl=plot_pl, 1601 plot_volume=plot_volume, 1602 plot_drawdown=plot_drawdown, 1603 smooth_equity=smooth_equity, 1604 relative_equity=relative_equity, 1605 superimpose=superimpose, 1606 resample=resample, 1607 reverse_indicators=reverse_indicators, 1608 show_legend=show_legend, ... 348 sizing_mode=sizing_mode, 349 ) 351 return gpTypeError: bokeh.models.tools.Toolbar() got multiple values for keyword argument 'logo'
Steps to Reproduce
1. create a simple strategy class 2. create a backtest object 3. backtest the strategy using run() 4. plot the strategy using plot()
class BBtrategy(Strategy): def init(self): #some indicator logic pass def next(self): #some trading rules pass backtest = Backtest(eur_usd, BollingerBandsStrategy) backtest.run() backtest.plot()Additional info
* Backtesting version: 0.3.3 * `bokeh.__version__`: 3.2.2 * OS: Windows-10-10.0.22621-SP0
I was able to reproduce your error. Backtesting version: 0.3.3 doesn't seem to be compatible with latest bokeh versions.
To fix the issue I have downgraded to bokeh==2.4.3 and was able to run your sample code.
Step 1 (Given you are using pip as your package manager)
pip uninstall bokeh
Step 2
pip install bokeh==2.4.3
Now you should be able to run your code just fine. Note other versions of bokeh might work fine as well but 2.4.3 is the one I've been using ever since without issues.
Hope that helps.
Regards,
Dominik
from backtesting.py.
@DominikBerger01 It works, thank you very much!
from backtesting.py.
This is a problem with bokeh and they indicate on their github that it has been fixed in Version 3.3 which was due out in Aug 2023
from backtesting.py.
Hey, im getting the same error;( bokeh 3.3.0 didn't work for me.
Are there any solutions?
Same here
from backtesting.py.
I realise that the problem that I posted is caused by installed pandas version 2.1. Apparently, the parameter method has been deprecated and removed after pandas 2.0.
By installing pandas 1.5.2, it is able to plot.
pip install pandas==1.5.2
from backtesting.py.
Not sure how to fix the code, any ideas?
File ~/.local/lib/python3.10/site-packages/backtesting/_plotting.py:148, in _maybe_resample_data.<locals>._group_trades.<locals>.f(s, new_index, bars)
147 mean_time = int(bars.loc[s.index].view(int).mean())
--> 148 new_bar_idx = new_index.get_loc(mean_time, method='nearest')
149 return new_bar_idx
TypeError: Index.get_loc() got an unexpected keyword argument 'method'
from backtesting.py.
Not sure how to fix the code, any ideas?
File ~/.local/lib/python3.10/site-packages/backtesting/_plotting.py:148, in _maybe_resample_data.<locals>._group_trades.<locals>.f(s, new_index, bars) 147 mean_time = int(bars.loc[s.index].view(int).mean()) --> 148 new_bar_idx = new_index.get_loc(mean_time, method='nearest') 149 return new_bar_idx TypeError: Index.get_loc() got an unexpected keyword argument 'method'
Your error differs from the one above. Refer to this issue where yours has been solved: #987
from backtesting.py.
Related Issues (20)
- bokeh 3.2.2 breaks plotting
- ValueError: Short orders require: TP (1890.425) < LIMIT (1886.10523) < SL (1890.455)
- How to add a dollar amount for take profit and stop loss
- Backtest results plot break when using yfinance data HOT 3
- Timezone not respected in charts HOT 1
- Cant find open positions
- Runup and drawdown of each trade
- How can I add compound in trades HOT 1
- How to get trades dataframe contain last trade that is still active?
- Code handling when some of the OHLC value is empty
- Why Sharpe, Sortino and Calmar Ratio all show 0? HOT 1
- Can I choose other Buy/Sell prices rather than Open/Close prices?
- BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale HOT 1
- A single trade wipes out all the cash HOT 4
- How to trade multiple varieties at the same time
- The get_loc() method of the Index class in pandas does not have a method argument. HOT 2
- number of days in trade mistmached
- if sell at close, and close value is fixed, still the final equity value is strange HOT 1
- Waiting a couple bars or minutes after a trade is closed before getting into another one? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backtesting.py.