A new IB integration using ib_insync
ultra1971 last edited by
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.
run-out last edited by
@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.
vladisld 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 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).
@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