How to read date and time when they are in same column using GenericCSVData
I have CSV file in following format providing hourly data.
Timestamp,Open,High,Low,Close,Volume,Volume (Currency),Weighted Price 9/7/2017 0:00,4605.81,4609.8,4534.29,4539.97,342.08,1563456.99,4570.39 9/7/2017 1:00,4539.95,4571.16,4480,4507.51,532.02,2405813.27,4522.06
I don't have separate time column, both date and time are in column 0. But I need to be able to read hours.
I am using following code:
data = bt.feeds.GenericCSVData( dataname=datapath, datetime=0, open=1, high=2, low=3, close=4, volume=5, openinterest=-1, fromdate=datetime(2017,10,9), todate=datetime(2017,10,12), separator=',', dtformat=('%m/%d/%Y %H:%M')
It compiles and works without a problem, but I am not able to read the hour in next() method of strategy.
It can read date, but not the hour.
Could you please advise on how to read the hour back when I need it,
for example I want to print date and hour of the day in logs ?
Same error as in your other question: https://community.backtrader.com/topic/874/incorrect-plotting-but-signal-is-correct/