Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting does not work with Bokeh v3.0 #803

Open
aicheung opened this issue Nov 8, 2022 · 12 comments
Open

Plotting does not work with Bokeh v3.0 #803

aicheung opened this issue Nov 8, 2022 · 12 comments
Labels
bug Something isn't working upstream Issue affects a dependency of ours

Comments

@aicheung
Copy link

aicheung commented Nov 8, 2022

Expected Behavior

I installed the tool and all required libraries on Ubuntu 22.04, Python 3.11.0 and ta-lib (compiled from latest source code 0.4.0). The backtest from the example code on home page was run. The test itself ran without

problems but the plot html does not work. It should show the graph.

Actual Behavior

Please see the attached. The html layout is not working. Strangely, no JS error from browser console.

Steps to Reproduce

  1. Install backtesting.py
  2. Run the example code on the project home page
  3. Open the plot in IE Edge

Additional info

Screenshot 2022-11-08 120227
Screenshot 2022-11-08 120313

  • Backtesting version: 0.3.3
@jackjiang871
Copy link

Downgrading
bokeh==3.0.1
to
bokeh==2.4.3
fixed this issue for me

@aicheung
Copy link
Author

aicheung commented Nov 9, 2022

Downgrading bokeh==3.0.1 to bokeh==2.4.3 fixed this issue for me

Thank you. I also fixed it by using Python 3.7 instead

@kernc
Copy link
Owner

kernc commented Nov 25, 2022

This is Bokeh bugs:
bokeh/bokeh#12614
bokeh/bokeh#12627

Please upvote, fix.

@kernc kernc pinned this issue Nov 25, 2022
@kernc kernc added the upstream Issue affects a dependency of ours label Nov 25, 2022
@kernc kernc changed the title Plotting does not work Plotting does not work with Bokeh v3.0 Nov 29, 2022
@micascheid
Copy link

Same issue here using the following for now:
python=3.8.15
bokeh=2.4.3

@kiann00
Copy link

kiann00 commented Jan 1, 2023

doesn't work for python 3.9, including the workaround of switching bokeh into version 2.4.3

anyone knows?

@dshetyo
Copy link

dshetyo commented Jan 16, 2023

Doesnot work for python 3.9

@bashu
Copy link

bashu commented Jan 22, 2023

Downgrading
bokeh==3.0.1
to
bokeh==2.4.3
fixed this issue for me

Does work for python 3.10 on macOS

@rogerc
Copy link

rogerc commented Jan 22, 2023

@bashu while issue gets resolved upstream, running the line below got it working using bokeh version 2.4.2 in MacOS with python 3.9.6 and Backtesting 0.3.3

 pip install --force-reinstall bokeh==2.4.2

@dwellingnerd
Copy link

dwellingnerd commented Feb 11, 2023

If your attempt still can't work maybe you can try the code below, it does work for me.

don't type like this:
import backtesting
backtesting.set_bokeh_output(notebook=False)

try this:
from backtesting import set_bokeh_output
set_bokeh_output(notebook=False)

my version info below:
Spyder 5.3.3
Python 3.8.12
bokeh 2.4.3
backtesting 0.3.3

@AaroncoolPx
Copy link

AaroncoolPx commented Oct 3, 2023

I realise that the problem was probably caused by the 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

Hope this helps for the time being.

@AaroncoolPx
Copy link

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'

@tuanphongpham
Copy link

bt.plot does not work for me. I have tried all the suggested above solutions but no one worked. Always coped with error: "Bound method Backtest.plot of <backtesting.backtesting.Backtest object at 0x7dc0f4917520"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Issue affects a dependency of ours
Projects
None yet
Development

No branches or pull requests