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/

    A new IB integration using ib_insync

    General Code/Help
    6
    8
    641
    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.
    • ultra1971
      ultra1971 last edited by

      Hey, guys!

      I really appreciate the support of this community and also the work of Daniel behind backtrader. I have extended and created my own framework based on backtrader, there is nothing like this out there.

      So your help is needed again, but in this case testing this version of the IB Store (Broker and DataFeed) using async integration with Interactive Brokers through ib_insync. I believe that this feature is one of the most recurrent improvement request for backtrader (and also a need for myself).

      The repo is here: https://github.com/ultra1971/backtrader_ib_insync

      Remember this an alpha+ version but fully working in my dev environment.

      During the stress testing that I ran with the tick price implementation, an average of 3 orders per second were reached, very promising. The connection stability is another improvement, this means no more hangs and this is something that you're looking for in any algotrading platform.

      You can find most of the original IB Store logic are there, cover most of the functionality, but happy to complete this with your support.

      A special thanks to the ib_insync community and of course to Ewald for keep this project active.

      Finally, this is the best way that I find to give you back my appreciation, thanks.

      Regards

      run-out D vladisld J 5 Replies Last reply Reply Quote 3
      • run-out
        run-out @ultra1971 last edited by

        @ultra1971 This is excellent. I will deep dive into this later today when my day opens up!

        RunBacktest.com

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

          @ultra1971 great work, will try this out. Thanks for your work.

          1 Reply Last reply Reply Quote 0
          • vladisld
            vladisld @ultra1971 last edited by

            @ultra1971 Kudos, Thanks for sharing. Interesting to know how you've tested it. It would be great if automation tests could be in place, so any further changes could be done with more confidence.

            I was thinking about providing mock implementation for ibpy ( or ib_insync) or even write a simple mock for IB networking interface for testing purposes only - had no time to complete it unfortunately.

            ultra1971 1 Reply Last reply Reply Quote 0
            • ultra1971
              ultra1971 @vladisld last edited by

              @vladisld thanks, only smoke tests were performed, a more complete automated testing would be great.

              Taking in mind that my goal was replace IBpy by ib_insync, my concerns are more related to order and position sync between IB and backtrader, into the new broker class.

              The new Store implements the async use of ib_insync, i.e. all connectivity control with IB rely on the new api lib

              The new data feed also take benefit of this, realtime bars (5s) are working really good, but also I have implemented price base tick if rtb=False.
              It's important to avoid the IB requirements for hist data submitting several request in a short period of time. (https://interactivebrokers.github.io/tws-api/historical_limitations.html#pacing_violations).

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

                @ultra1971 oh, i noticed now this topic is posted twice, i added some suggestions in https://community.backtrader.com/topic/3773/a-new-ib-integration-using-ib_sync/6

                1 Reply Last reply Reply Quote 1
                • J
                  Jason 1 @ultra1971 last edited by

                  @ultra1971

                  New to this.

                  My account is setup to use adviser, and so I get

                  You must specify an allocation(either a single accunt, group or profile)

                  How do I do that in your code?

                  I tried self.buy(profile = 'All-in')

                  All-in was setup in my ib

                  Any ideas or suggestions?

                  Mariano Volpedo 1 Reply Last reply Reply Quote 0
                  • Mariano Volpedo
                    Mariano Volpedo @Jason 1 last edited by

                    @jason-1 based on my IB and ib_insync knowledge, this is a setup into IB, no impact on order fullfilment, as this piece of code try to solve.

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