Lean.Brokerages.InteractiveBrokers
Lean.Brokerages.InteractiveBrokers copied to clipboard
GetContractDetails Delay Order Execution
Expected Behavior
When the algorithm places an order, the contract details should have been cached before.
Actual Behavior
The contract details are fetched before we place the orders. If we subscribe to Interactive Brokers' data, fetch and cache this information on subscribe. On the other hand, if we use an alternative feed, e.g. QuantConnect's, the contract details are requested to IB before the orders are placed.
Potential Solution
Perhaps we could fetch them during the heartbeats.
Reproducing the Problem
Deploy live algorithm with QuantConnect data and place one order to open a position and another to close it. The roundtrip time of the first will be longer. See in the syslog that GetContractDetails is called before the first order.
Checklist
- [x] I have completely filled out this template
- [x] I have confirmed that this issue exists on the current
masterbranch - [x] I have confirmed that this is not a duplicate issue by searching issues
- [x] I have provided detailed steps to reproduce the issue
An algorithm placed limit orders to force getting contract details to cache them and the speed increased. 20 orders that fetched contract details took 3.5 seconds against 1.5 seconds of 20 orders that didn't fetch it.