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/

    oandav20 resampling from 15m to 4h shows extra bars.

    General Discussion
    5
    8
    166
    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.
    • A
      ahoyahoy last edited by

      I'm using oandav20 and resampling from 15m up to 4h and the 1D. The problem is in 4h chart data I see non-aligned bars and it looks like the time axis is broken:

      eur_usd_EUR_USD_4h copy.png

      I've tried various combinations of the bar2edge and rightedge and adjbartime flags but still has the problem. I've also tried shifting the sessionstart but the daily chart needs this to be at 23 (aligning with broker time).

      When I search through the data dump (using the writer) I see extra bars coming out of the resampling aligning to the yellow arrows:

      2020-05-14 00:00:00
      2020-05-14 04:00:00
      2020-05-14 08:00:00
      2020-05-14 12:00:00
      2020-05-14 13:45:00. <-- what?
      2020-05-14 16:00:00
      2020-05-14 20:00:00
      ...
      
      2020-05-19 04:00:00
      2020-05-19 08:00:00
      2020-05-19 11:15:00 <-- what?
      2020-05-19 12:00:00
      

      any pointer appreciated, I've been a coder for 15 years so hit me with the hardcore detail if needed

      Here's my setup, if this is of help. Cheers

      datakwargs = dict(
          timeframe=bt.TimeFrame.Minutes,
          compression=15,
          stream_timeout=60,
          historical=args.historical,
          fromdate=fromdate,
          tz=args.timezone,
          backfill_start=True,
          backfill=True,
          sessionstart=datetime.time(23, 00), #oanda uses singapore time so 23 in BST.
          sessionend=datetime.time(23, 00)
      )
      
      rekwargs4h = dict(
          timeframe=bt.TimeFrame.Minutes, compression=240,
          bar2edge=False, 
          adjbartime=False,
          rightedge=False,
          takelate=False
      )
      
      rekwargs1d = dict(
          timeframe=bt.TimeFrame.Days, compression=1,
          bar2edge=False, 
          adjbartime=False, 
          rightedge=False,
          takelate=False
      )
      
      #Loop through the list adding to cerebro.
      for i in range(len(datalist)):
          data = DataFactory(dataname=datalist[i], **datakwargs)
          # enabling this seems to break daily graph
          cerebro.resampledata(data, name=datalist[i], timeframe=datakwargs['timeframe'], compression=datakwargs['compression'])
              
          cerebro.resampledata(data, name=datalist[i], **rekwargs4h)
          
          # day
          cerebro.resampledata(data, name=datalist[i], **rekwargs1d)
         
      config = dict()
      ``
      1 Reply Last reply Reply Quote 0
      • A
        ahoyahoy last edited by

        ok I've moved this to the right topic, admins feel free to delete

        1 Reply Last reply Reply Quote 0
        • D
          dasch last edited by

          this may be due to the sessionend value and the first time you receive a data update. but this is just a guess. If this does not appear without the session end value, investigate this.

          1 Reply Last reply Reply Quote 0
          • amulya agarwal
            amulya agarwal last edited by

            Can you provide the entire source code or a link to it?

            1 Reply Last reply Reply Quote 0
            • D
              dasch last edited by

              These two settings:

              sessionstart=datetime.time(23, 00), #oanda uses singapore time so 23 in BST.
              sessionend=datetime.time(23, 00)

              amulya agarwal 1 Reply Last reply Reply Quote 0
              • amulya agarwal
                amulya agarwal @dasch last edited by

                @dasch How are we supposed to get data in different timeframe like 30mins or 1h rather than 1d which is a default.

                B 1 Reply Last reply Reply Quote 0
                • B
                  bigdavediode @amulya agarwal last edited by

                  @amulya-agarwal

                  Use compression, as above, compression 1 for 1 minute bars if you wish, as below:

                          timeframe=bt.TimeFrame.Minutes,
                          compression=barsize,
                          useRTH=False,
                          #outsideRth=True,    fill orders outside rth -- use for orders, not here...
                          sessionstart=datetime.time(9, 30, 0),
                          sessionend=datetime.time(16, 30, 0),
                  

                  ...and then your adddata or resample line using these arguments.

                  Yaroslav Horyslavets 1 Reply Last reply Reply Quote 1
                  • Yaroslav Horyslavets
                    Yaroslav Horyslavets @bigdavediode last edited by

                    @bigdavediode Thanks sir!!! I had a lot of problem because forgot use this parameter in my custom data feed!

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