Not plotting properly with almost identical data that does
-
I have two daily timeframe 10 day data sets (one that works and one that doesn't) which I am using to try to reduce this problem. One is example oracle data (A) which plots and buys properly and the other is fake ethusdt data (B) which doesn't buy or plot properly. The strategy is simply buy on day 3 close on day 7. I changed the dates so they are identical. The only data that is different are the prices.
import backtrader class TheStrategy(backtrader.Strategy): def __init__(self): self.period = 0 def next(self): self.period += 1 if self.period == 3: self.buy() if self.period == 7: self.close() cerebro = backtrader.Cerebro() cerebro.broker.setcash(1000) print("Starting $ %.2f" % cerebro.broker.getvalue()) # Get Data data = backtrader.feeds.GenericCSVData(dataname='ethusdt.csv', dtformat='%Y-%m-%d', openinterest=-1, volume=-1) #data = backtrader.feeds.GenericCSVData(dataname='oracle.csv', dtformat='%Y-%m-%d', openinterest=-1, volume=-1) # Add Data cerebro.adddata(data) # Add Strategy cerebro.addstrategy(TheStrategy) # Run cerebro.run() print("Final $ %.2f" % cerebro.broker.getvalue()) cerebro.plot(volume=False)
Oracle Data
Date,Open,High,Low,Close 1995-01-03,2.179012,2.191358,2.117284,2.117284 1995-01-04,2.123457,2.148148,2.092592,2.135803 1995-01-05,2.141975,2.148148,2.08642,2.092592 1995-01-06,2.092592,2.154321,2.061728,2.117284 1995-01-09,2.135803,2.179012,2.12963,2.179012 1995-01-10,2.191358,2.216049,2.185185,2.185185 1995-01-11,2.203704,2.216049,2.098765,2.12037 1995-01-12,2.123457,2.12963,2.08642,2.104938 1995-01-13,2.12963,2.145062,2.074074,2.080247
Fake Eth Data (Same Dates)
Date,Open,High,Low,Close 1995-01-03,1892,1893,1887,1888 1995-01-04,1888,1892,1886,1888 1995-01-05,1888,1890,1885,1887 1995-01-06,1887,1891,1887,1890 1995-01-09,1889,1892,1889,1892 1995-01-10,1892,1902,1892,1900 1995-01-11,1900,1908,1899,1907 1995-01-12,1907,1907,1901,1902 1995-01-13,1901,1903,1901,1901
(A) Oracle
(B) Ethusdt
As you can see the ETH plotting does not buy and does not plot. It seems this problem is impossible and would appreciate any info pointing in the right direction.Notes: For some reason the eth data shows dates on the bottom in the plot ( I dont know why).
Note2: I even tried reducing the eth data down until it does plot, it seems that it plots properly when the prices where 3 digits, makes no sense.