Hi,
Sorry in advance for the long post.
My goal is to integrate the Lean Engine into an existing IB API-based application. I'm interested in reducing the complexity of my existing application by using Lean's more elegant abstractions. I'm also looking to leverage its indicators framework.
First off, thanks for Lean. I look forward to upgrading my account soon to support this great work!
I have a few specific questions for the community, below - but one general question first. Are there any good sample projects that integrate Lean with IB?
Unfortunately IB is down today for maintenance, so I can't really test anything.
My specific questions::
I'm just working through some of the Lean code to see how it works, but there is so much code that I'm struggling a bit with a few things.
- can I/should I create multiple instances of InteractiveBrokersBrokerage to have multiple algorithms run concurrently? If no, my next question probably doesn't need to be answered. It's possible that this class is not meant to be directly instantiated by my code at all??
- clientID=0 seems to be hardcoded in InteractiveBrokersBrokerage.cs. IB supports multiple clientIDs concurrently. Lean's connection seems to take a single algorithm per instance of IB. Can I create multiple instances and run multiple Lean algorithms at once? If yes, would each need its own clientId? The comments in the Lean code suggest that clientId=0 is the only one that handles cancelling/modifying orders, but I wonder if that is only true for TWS (vs IBGateway) or if the comment in the code is just out of date. Here is the content from the IB site on the IB Gateway setting for Master API Client Id:
"Master API client ID - The API client with the specified client ID will receive all orders, even those placed by other API clients. This differs from the Client ID of “0” which will receive all orders sent from the TWS GUI."
This implies orders can flow through a clientId specified in this IB Gateway setting. Is the comment in the Lean code just calling out cancels and updates? Just for TWS, or IB Gateway too?
- IF I can create multiple instances of InteractiveBrokersBrokerage, will this cause other problems with Lean's broader feature set (sorry, there is a lot of code to go through in Lean and IB is down today, I'm just asking here in the event someone has tried this kind of Lean integration)?
If Lean won't work with multiple algos running at once, I guess I could just try to integrate the indicators from Lean into my existing application - but I'm keen on shifting my application to Lean's overaching model.
Thanks,
S.
Shile Wen
Hi Stephen,
Lean is not designed to handle multiple algorithms through IB.
Best,
Shile Wen
Stephen Newport
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!