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 time axis misplaced #284

Open
emiliobasualdo opened this issue Mar 20, 2021 · 3 comments
Open

Plotting time axis misplaced #284

emiliobasualdo opened this issue Mar 20, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@emiliobasualdo
Copy link

I'm watching a misplaced time axis for 1min OHLC candles.
As seen in the image below, the minutes of the time axis do not match with that of the tooltip.

Actual Behavior

Screen Shot 2021-03-20 at 13 19 03

Steps to Reproduce

bt = Backtest(1minute_ohlc_candles, Strat)
bt.plot(plot_equity=True, superimpose=False, show_legend=True, plot_return=False, plot_drawdown=False)
  • Backtesting version: 0.3.1
@kernc
Copy link
Owner

kernc commented Mar 21, 2021

Can you maybe share the first 50 minutes of said data to investigate?

@emiliobasualdo
Copy link
Author

emiliobasualdo commented Mar 22, 2021

Yes sorry, my bad.

Binance_DASHUSDT_minute_10000_clean.csv.zip

    class SmaCross(Strategy):
        def init(self):
            price = self.data.Close
            self.ma1 = self.I(SMA, price, 10)
            self.ma2 = self.I(SMA, price, 20)

        def next(self):
            if crossover(self.ma1, self.ma2):
                self.buy()
            elif crossover(self.ma2, self.ma1):
                self.sell()

    df = pd.read_csv("file.csv", index_col=0, parse_dates=True, infer_datetime_format=True)
    bt = Backtest(df, SmaCross, commission=.0, exclusive_orders=True, cash=100000)
    results = bt.run()
    bt.plot(results=results, plot_equity=True, superimpose=False, show_legend=True, plot_return=False, plot_drawdown=False)

@emiliobasualdo
Copy link
Author

@kernc did you have a chance to look at it?

@kernc kernc added the bug Something isn't working label Feb 4, 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