backtesting.py icon indicating copy to clipboard operation
backtesting.py copied to clipboard

Plotting time axis misplaced

Open emiliobasualdo opened this issue 4 years ago • 3 comments

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

emiliobasualdo avatar Mar 20 '21 16:03 emiliobasualdo

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

kernc avatar Mar 21 '21 03:03 kernc

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 avatar Mar 22 '21 13:03 emiliobasualdo

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

emiliobasualdo avatar Apr 01 '21 18:04 emiliobasualdo