Second time one of my clients faced this problem so I decided to discuss it and maybe there is a better solution to it.
Basically, in live trading, when we send an order to brokerage, LEAN first fetches some information from the brokerage for the symbol to make sure that order is valid and it shouldn't be rejected. On InteractiveBrokers this creates a delay of more than 1 second before order is actually sent to brokerage, and for market orders this can create quite a bit of additional slippage.
I've made a workaround for this by sending market-on-close orders that I then cancel, but this solution is ugly, it pollutes orders list (that is hard to navigate already, can you please add filters?) and for other instruments market-on-close orders may not be available and you will have to use limit orders, which is even less reliable and more ugly.
Maybe there is a better way to fetch that information from the brokerage before sending orders? If not, please add it.
Mia Alissi
Here’s an example showing how you can proactively pre-fetch Interactive Brokers (IB) symbol/account information at the start of your algorithm to avoid order path delays due to brokerage-side validation:
How this helps:
For the QuantConnect team:
Sources: Getting Started - QuantConnect.com, Brokerage Model Algorithm, docs writing algorithms securities asset classes us equity shorting, Interactive Brokers - QuantConnect.com, Warm Up Periods - QuantConnect.com
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.
Yuri Lopukhov
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!