I am trying to backtest a strategy with Backtrader and have a problem while printing date & time for each iteration (time stay on 23:59:59).
Here are the first lines of my dataset:
What is printed on the console :
And finally how I load my data :
data = bt.feeds.GenericCSVData(dataname="BTCUSD_15MIN.csv",
datetime=0,
fromdate=datetime.datetime(2015,1,13),
todate=datetime.datetime(2015,1,15),
open=1,
high=2,
low=3,
close=4,
openinterest=-1,
time=-1,
volume=-1,
dtformat="%Y-%m-%d %H:%M:%S")
Has someone already got this issue?
That for sure only solved your problem by chance (because what you chose is smaller than the actual reality)
Your data is obviously 15-minutes
based. But without specification, you let the default values in place: bt.TimeFrame.Daily
, which gives you the end of the day for each bar. No surprises there.
The right choice would therefore be:
timeframe=bt.TimeFrame.Minutes,
compression=15,
This is explained in the backtrader community in several posts and in the FAQ.