Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. kreut
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    K
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 1
    • Controversial 0
    • Groups 0

    kreut

    @kreut

    1
    Reputation
    308
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    kreut Unfollow Follow

    Best posts made by kreut

    • RE: 4 hour time intervals

      @ab_trader Definitely a step in the right direction! I've updated my code:

      data = btfeeds.GenericCSVData(
          dataname='ada.csv',
          fromdate=datetime.datetime(2000, 1, 1),
          todate=datetime.datetime(2018, 12, 31),
          timeframe=bt.TimeFrame.Minutes, compression=240,
          nullvalue=0.0,
          dtformat=('%Y-%m-%d %H:%M:%S'),
          datetime=0,
          high=1,
          low=2,
          open=3,
          close=4,
          volume=-1,
          openinterest=-1
      )
      

      and now, my buy creates/buy executes are acting as expected (the timing seemed to be "off" before). However, the printout remains unchanged; backtrader still seems to ignore my hours at least in the cosmetic sense. Is there another setting that I need to add to make sure the time component gets printed out?

      Thanks!

      posted in General Code/Help
      K
      kreut

    Latest posts made by kreut

    • RE: 4 hour time intervals

      @fintrading Got it! Thanks...

      posted in General Code/Help
      K
      kreut
    • RE: 4 hour time intervals

      @ab_trader Definitely a step in the right direction! I've updated my code:

      data = btfeeds.GenericCSVData(
          dataname='ada.csv',
          fromdate=datetime.datetime(2000, 1, 1),
          todate=datetime.datetime(2018, 12, 31),
          timeframe=bt.TimeFrame.Minutes, compression=240,
          nullvalue=0.0,
          dtformat=('%Y-%m-%d %H:%M:%S'),
          datetime=0,
          high=1,
          low=2,
          open=3,
          close=4,
          volume=-1,
          openinterest=-1
      )
      

      and now, my buy creates/buy executes are acting as expected (the timing seemed to be "off" before). However, the printout remains unchanged; backtrader still seems to ignore my hours at least in the cosmetic sense. Is there another setting that I need to add to make sure the time component gets printed out?

      Thanks!

      posted in General Code/Help
      K
      kreut
    • 4 hour time intervals

      Hi,

      I'm just getting used to Backtrader and I'm trying to use the Quick Start guide just slightly tweaked. Basically, my data is in 4 hour intervals, but I can't quite see how to get Backtrader to keep things at the 4 hour level. In particular, I'm using:

      data = btfeeds.GenericCSVData(
      dataname='my.csv',
      fromdate=datetime.datetime(2000, 1, 1),
      todate=datetime.datetime(2018, 12, 31),
      nullvalue=0.0,
      dtformat=('%Y-%m-%d %H:%M:%S'),
      datetime=0,
      high=1,
      low=2,
      open=3,
      close=4,
      volume=-1,
      openinterest=-1
      )

      Then, I'm using:

      def log(self, txt, dt=None):
      ''' Logging function for this strategy'''
      dt = dt or self.datas[0].datetime.date(0)
      print('%s, %s' % (dt.strftime('%Y-%m-%d %H:%M:%S'), txt))

      However, my print out is looking like:

      2017-12-06 00:00:00, Close, 0.00000994
      2017-12-06 00:00:00, Close, 0.00001009
      2017-12-06 00:00:00, Close, 0.00000940

      i.e. the hours are all 00:00:00. Any help would be appreciated.

      posted in General Code/Help date-time
      K
      kreut