Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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()

    General Code/Help
    2
    3
    22
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      genkisushijai last edited by

      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!!

      1 Reply Last reply Reply Quote 0
      • run-out
        run-out last edited by

        See if this recent post helps.

        1 Reply Last reply Reply Quote 1
        • G
          genkisushijai last edited by

          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!

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }