For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Time doesn't change but Date does



  • I have been following examples, but whatever I do, the time won't change along with the date. My code looks as follows:

    class MyStrategy(bt.Strategy):
            def __init__(self):
                self.dataclose = self.datas[0].close
        
            def next(self):
                print(self.datas[0].datetime.date(0), self.datas[0].datetime.time(0))
    
    cerebro = bt.Cerebro()
    
    data = btfeeds.GenericCSVData(
        dataname='data.csv',
    
        dtformat=('%Y-%m-%d'),
        tmformat=('%H.%M.%S'),
        
        datetime=0,
        time=1,
        open=2,
        high=3,
        low=4,
        close=5,
        volume=6,
        openinterest=-1
    )
    

    cerebro.adddata(data)

    cerebro.addstrategy(MyStrategy)

    cerebro.run()

    The output looks as follows:

    2010-03-22 23:59:59.999989
    2010-03-22 23:59:59.999989
    2010-03-22 23:59:59.999989
    2010-03-22 23:59:59.999989
    2010-03-22 23:59:59.999989

    continuing like this all the way through. The csv file looks like this:

       date 	          time 	  open 	  high 	 low 	  close 	ticks
    

    0 2010-03-01 00.24.00 0.89887 0.89887 0.89886 0.89886 2
    1 2010-03-01 00.25.00 0.89884 0.89888 0.89870 0.89881 20
    2 2010-03-01 00.26.00 0.89878 0.89883 0.89878 0.89883 7




Log in to reply
 

});