A new IB integration using ib_insync
-
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
-
@ultra1971 This is excellent. I will deep dive into this later today when my day opens up!
-
@ultra1971 great work, will try this out. Thanks for your work.
-
@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.
-
@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). -
@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
-
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?
-
@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.