Open dindom999 opened 2 years ago
It happened when resample 5m to 60m and plot. I am not sure it's from resampling or plotting. Any one can reproduce it by using the sample data in source code.
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import time import backtrader as bt class St(bt.Strategy): params = dict(multi=True) def __init__(self): self.pp = pp = bt.ind.PivotPoint(self.data1) pp.plotinfo.plot = False # deactivate plotting if self.p.multi: pp1 = pp() # couple the entire indicators self.sellsignal = self.data0.close < pp1.s1 else: self.sellsignal = self.data0.close < pp.s1() def next(self): txt = ','.join( ['%04d' % len(self), '%04d' % len(self.data0), '%04d' % len(self.data1), self.data.datetime.date(0).isoformat(), '%.2f' % self.data0.close[0], '%.2f' % self.pp.s1[0], '%.2f' % self.sellsignal[0]]) print(txt) cerebro = bt.cerebro.Cerebro() # Data feed data_file = r"D:\tmp\backtrader\datas\2006-min-005.txt" # D:\tmp\backtrader\datas is where the backtrader source folder data0 = bt.feeds.BacktraderCSVData(dataname=data_file, timeframe=bt.TimeFrame.Minutes, compression=5) cerebro.adddata(data0) cerebro.resampledata(data0, timeframe=bt.TimeFrame.Minutes, compression=60) cerebro.addanalyzer(bt.analyzers.Returns, _name="RE") cerebro.addanalyzer(bt.analyzers.TradeAnalyzer, _name="TA") cerebro.addstrategy(St) btrs1 = cerebro.run() pstart=0 pend=100 cerebro.plot(start=pstart, end=pend, style='candle')
60minutes view is obviously incorrect
But when I change plot end to 200 pstart=0 pend=200 It's correct now.
pstart=0 pend=200
I have fix this bug and fire a pull requests https://github.com/backtrader2/backtrader/pull/84/commits
It happened when resample 5m to 60m and plot. I am not sure it's from resampling or plotting. Any one can reproduce it by using the sample data in source code.
60minutes view is obviously incorrect
But when I change plot end to 200![Figure_0](https://user-images.githubusercontent.com/5274818/146348310-33e794dc-974c-4620-8b82-4860a02c84e3.png)
pstart=0 pend=200
It's correct now.