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

Backtest plotting results in empty graph #840

Open
trueToastedCode opened this issue Dec 13, 2022 · 11 comments
Open

Backtest plotting results in empty graph #840

trueToastedCode opened this issue Dec 13, 2022 · 11 comments
Labels
duplicate This issue or pull request already exists

Comments

@trueToastedCode
Copy link

trueToastedCode commented Dec 13, 2022

Expected Behavior

Graph should not be empty

Actual Behavior

There are also tons of warnings in the console...

/Users/lennard/opt/miniconda3/envs/torch/lib/python3.9/site-packages/backtesting/_plotting.py:122: UserWarning:

Data contains too many candlesticks to plot; downsampling to '1H'. See `Backtest.plot(resample=...)`

/Users/lennard/opt/miniconda3/envs/torch/lib/python3.9/site-packages/backtesting/_plotting.py:148: FutureWarning:

Passing method to Int64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.

BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale
/Users/lennard/opt/miniconda3/envs/torch/lib/python3.9/site-packages/bokeh/models/formatters.py:399: UserWarning:

DatetimeFormatter scales now only accept a single format. Using the first prodvided: '%d %b' 

BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale
/Users/lennard/opt/miniconda3/envs/torch/lib/python3.9/site-packages/bokeh/models/formatters.py:399: UserWarning:

DatetimeFormatter scales now only accept a single format. Using the first prodvided: '%m/%Y' 

Steps to Reproduce

... doesn't matter ...

bt = Backtest(dfpl, MyStrategy, cash=100, margin=1/10, commission=.0)

# backtesting.set_bokeh_output(notebook=False) - doesn't matter

bt.plot(show_legend=False)

Additional info

Bildschirm­foto 2022-12-13 um 17 49 54

  • Backtesting version: 0.3.3
  • bokeh.__version__: 3.0.2
  • Using Jupyter Notebook
  • OS: MacOS Ventura 13.0 (Apple Silicon)

yes there are stats if I run the strategy:

Start                     2020-01-01 22:00:00
End                       2020-12-31 21:55:00
Duration                    364 days 23:55:00
Exposure Time [%]                    4.700638
Equity Final [$]                   139.304018
Equity Peak [$]                    139.533855
Return [%]                          39.304018
Buy & Hold Return [%]                8.932887
Return (Ann.) [%]                   30.478123
Volatility (Ann.) [%]               17.919015
Sharpe Ratio                         1.700882
Sortino Ratio                        3.531841
Calmar Ratio                         4.042517
Max. Drawdown [%]                   -7.539393
Avg. Drawdown [%]                   -0.858869
Max. Drawdown Duration       55 days 19:15:00
Avg. Drawdown Duration        3 days 12:49:00
# Trades                                  748
Win Rate [%]                        49.465241
Best Trade [%]                       0.222753
Worst Trade [%]                     -0.230765
Avg. Trade [%]                        0.00461
Max. Trade Duration           2 days 00:45:00
Avg. Trade Duration           0 days 00:27:00
Profit Factor                        1.269556
Expectancy [%]                       0.004625
SQN                                  2.384091
_strategy                          MyStrategy
_equity_curve                             ...
_trades                        Size  Entry...
dtype: object
@micascheid
Copy link

micascheid commented Dec 13, 2022

This issue falls in line with #803

Currently having to use python 3.8 with bokeh 2.4.3

@trueToastedCode
Copy link
Author

trueToastedCode commented Dec 13, 2022

Workaround
pip uninstall -y bokeh && pip install bokeh==2.4.3

@micascheid
Copy link

Workaround
pip uninstall -y bokeh && pip install bokeh==2.4.3

And thats working with python 3.9?

@trueToastedCode
Copy link
Author

Workaround
pip uninstall -y bokeh && pip install bokeh==2.4.3

And thats working with python 3.9?

Yes.

@micascheid
Copy link

Workaround
pip uninstall -y bokeh && pip install bokeh==2.4.3

And thats working with python 3.9?

Y

Just ran it with python 3.11. And got that working. Sticking with bokeh 2.4.3 for now.

@kernc kernc added the duplicate This issue or pull request already exists label Dec 16, 2022
@kiann00
Copy link

kiann00 commented Jan 1, 2023

Workaround
pip uninstall -y bokeh && pip install bokeh==2.4.3

And thats working with python 3.9?

Yes.

hmmm, I am also using python 3.9, and somehow this working around doesn't work

@trueToastedCode
Copy link
Author

trueToastedCode commented Jan 1, 2023

Workaround
pip uninstall -y bokeh && pip install bokeh==2.4.3

And thats working with python 3.9?

Yes.

hmmm, I am also using python 3.9, and somehow this working around doesn't work

I also needed to restart my Jupyter notebook… otherwise idk why it would not work for u

@krairy
Copy link

krairy commented Jan 5, 2023

Downgrading BokehJS from v3.0.3 to v2.4.3 worked for me too (Windows, Python 3.10, Jupyter server 6.4.12, IPython 8.4.0).
Thanks so much!

@stonematt
Copy link

I'm getting: Javascript Error: unable to decode an object of type 'Row'

@stonematt
Copy link

I take it back! something must have been cached. I ended up shutting down and actually restarting my machine and it worked! ugh.

@PlantBasedCrypto
Copy link

I'm running backtesting.py on vscode. I can see the chart displayed however I cannot see the stats. Any recommendation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

7 participants