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/

    Receiving data too late for minute bars using CCXT

    General Code/Help
    3
    3
    99
    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.
    • R
      rntrading last edited by

      Hi,
      I'm new to this platform, so, please excuse me if i havent posted my problem correctly.

      I'm pulling historical and live minute data from a broker feed using CCXT and the historical data is working perfectly. However, the on-going live bars are pulled in at random times and not the actual minute!

      I've included an example below:

      So, using the following code:

      cerebro = bt.Cerebro()
      
      hist_start_date = dt.datetime.utcnow() - dt.timedelta(minutes=10)
      data_min = bt.feeds.CCXT(exchange='ftx', symbol="BTC/USD", name="btc_usd_min", fromdate=hist_start_date, timeframe=bt.TimeFrame.Minutes)
      cerebro.adddata(data_min)
      cerebro.addstrategy(TestStrategy)
      cerebro.run()
      

      The following output is produced:

      historical data:
      2021-08-03 13:44:00 btc_usd_min 38587.0 38600.0 38585.0 38600.0 23909.0193 Minute 10 2021-08-03 14:44:25.408706

      live data:
      2021-08-03 13:45:00 btc_usd_min 38596.0 38625.0 38583.0 38606.0 380417.3058 Minute 11 2021-08-03 14:45:27.088786

      2021-08-03 13:46:00 btc_usd_min 38626.0 38635.0 38610.0 38631.0 595484.7427 Minute 12 2021-08-03 14:46:28.494754

      Why are the live minute bars for 14:45 being pulled in at 14:45:27?? If i start the program again at a different time, the minute bars get pulled in at different times again. It's very strange.

      Could somebody help with this? Thanks.

      E run-out 2 Replies Last reply Reply Quote 0
      • E
        EMR @rntrading last edited by

        @rntrading Just something I noticed which may help you dig your problem : According to your logs, historical data is also produced at hh:mm:25, also not at an exact minute end. So this may not be a live data problem.

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

          @rntrading Interesting question. It appears to me on a quick look that the data is correct/live when it arrives, but not matching up with the top of the hour time stamp.

          RunBacktest.com

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors