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

Displaying time on closing price on cerebro.run()



  • Hi everyone:

    Right now, when I call cerebro.run(), closing prices are shown along with its date, as seen below.

    Starting Portfolio Value: 10000.00
    2020-07-30, Close, 50.90
    2020-07-30, Close, 50.90
    2020-07-30, Close, 50.80
    2020-07-30, Close, 50.80

    The dates are all the same, as I imported 1 min data (I'm trying to implement an intraday trading strategy).

    Is there a way to display the time too in the closing prices (ex: 2020-07-30 09:30, Close, 50.90)? Thanks!!



  • See if this recent post helps.



  • I ended up fixing this by changing my def log function as follows:

    def log(self, txt, dt=None, doprint=False):
        ''' Logging function for this strategy'''
            if self.params.printlog or doprint:
                dt = dt or self.datas[0].datetime.date(0)
                time = self.data.datetime.time(0)
                print('%s %s, %s' % (dt.isoformat(), time, txt))
    
    

    And adding this parameter to GenericCsvData:

    timeframe=bt.TimeFrame.Minutes

    Thanks!


Log in to reply
 

});