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/

    Reduce the number of requests in ccxt live feed?

    General Code/Help
    2
    5
    220
    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.
    • B
      BorutF last edited by

      I am using the ccxbt library to retrieve live-data from binance. The problem is that my strategy only uses 15 minute intervals, so there is no need to make requests for the OHCLV every second, which it appears to be doing. I want to later scale the project to run several strategies concurrently and I am worried this calls will exceed Binance's limit of 1200 per minute.

      Is there any way to limit this calls, the strategy run only on full intervals anyway.

      G 1 Reply Last reply Reply Quote 0
      • G
        goloap @BorutF last edited by

        @borutf if all the strategies run off the same data you don't have to worry since the data will only be retrieved once and share to all your strategies. If you are trading multiple pairs, you can change the rateLimit parameter which will slow ccxt down and allow you to stay within the limit at the cost of latency to getting the data but a few seconds on a 15 minutes timeframe shouldn't be too critical.

        I agree with you that it would be great if the backtrader could simply wait until the next datapoint should be available before polling.

        Also I'm hoping the the websocket option in ccxt pro (which will become free in the coming months) will solve this problem.

        B 2 Replies Last reply Reply Quote 0
        • B
          BorutF @goloap last edited by

          @goloap Thank you very much.

          How exactly does rateLimit function? As far as I understand it is in milliseconds and a bigger number brings a bigger gap in between the requests, but I don't understand the magnitude of the effect?

          When I set it to 5000ms, I see it takes almost 25 seconds from one request to the other.

          1 Reply Last reply Reply Quote 0
          • B
            BorutF @goloap last edited by

            @goloap How would you the websocket with backtrader?

            G 1 Reply Last reply Reply Quote 0
            • G
              goloap @BorutF last edited by

              You can have a look at the throttle function in exchange.py (https://github.com/ccxt/ccxt/blob/master/python/ccxt/base/exchange.py) for the details. But basically the rateLimit is multiplied by a cost (which should be 1 most of the time). So with a 5000ms you should see a delay of 5 seconds. I'm not sure why you are seeing 25. Do you have multiple symbols?

              Regarding the websocket. I expect that it will be handled by ccxt transparently to backtrader, but will have to wait and see once it becomes available.

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