Skip to content

bt.plot() - crosshair's line does not go across between charts (vertical crosshair line) #1042

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

Closed
ck0099 opened this issue Aug 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@ck0099
Copy link

ck0099 commented Aug 8, 2023

Expected Behavior

Crosshair to show across all plots / subplots - You can see for a particular price, the matching crosshair line to the subchart's RSI value.
01_expected

Actual Behavior

Crosshair does not show across all plots / subplots - crosshair line does not show in subgraph
02_actual

Steps to Reproduce

1.Execute the following python code:

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning) # Suppress Future Depreciation Warning in ipynb

from backtesting import Backtest, Strategy
from backtesting.test import GOOG

from backtesting.lib import crossover, plot_heatmaps, resample_apply, barssince

import seaborn as sns # seaborn uses matplotlib
import matplotlib.pyplot as plt
import talib

class RsiOscillator(Strategy):

    # parameters for optimization:
    upper_bound = 70
    lower_bound = 30
    rsi_window = 14

    def init(self):
        price = self.data.Close
        self.daily_rsi = self.I(talib.RSI, price, self.rsi_window)

    def next(self):

        # BarsSince:
        # - Tell you how many bars ago it was true

        if (
                # Daily RSI is greater than upper
                self.daily_rsi[-1] > self.upper_bound
                and
                # 3 days ago the RSI is below upper
                barssince(self.daily_rsi < self.upper_bound) == 3
           ):
            self.position.close() 
        
        elif (
                # crossover(self.lower_bound, self.daily_rsi)
                self.lower_bound > self.daily_rsi[-1]
             ):
            self.buy(size=1)

bt = Backtest(GOOG, RsiOscillator, cash = 10_000)
stats = bt.run()
bt.plot()

Additional info

Python version: 3.10.4

PIP packages:

appnope==0.1.3
asttokens==2.2.1
backcall==0.2.0
Backtesting==0.3.3
bokeh==3.2.1
comm==0.1.4
contourpy==1.1.0
cycler==0.11.0
debugpy==1.6.7
decorator==5.1.1
executing==1.2.0
fonttools==4.42.0
ipykernel==6.25.0
ipython==8.14.0
jedi==0.19.0
Jinja2==3.1.2
jupyter_client==8.3.0
jupyter_core==5.3.1
kiwisolver==1.4.4
MarkupSafe==2.1.3
matplotlib==3.7.2
matplotlib-inline==0.1.6
nest-asyncio==1.5.7
numpy==1.25.2
packaging==23.1
pandas==2.0.3
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==10.0.0
platformdirs==3.10.0
prompt-toolkit==3.0.39
psutil==5.9.5
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.16.1
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2023.3
PyYAML==6.0.1
pyzmq==25.1.0
seaborn==0.12.2
six==1.16.0
stack-data==0.6.2
TA-Lib==0.4.27
tornado==6.3.2
traitlets==5.9.0
tzdata==2023.3
wcwidth==0.2.6
xyzservices==2023.7.0

@ck0099
Copy link
Author

ck0099 commented Aug 12, 2023

This issue is resolved once i downgraded to bokeh==2.4.3.

@ck0099 ck0099 closed this as completed Aug 12, 2023
@kernc kernc added upstream Issue affects a dependency of ours bug Something isn't working and removed upstream Issue affects a dependency of ours labels Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants