I have been having some issues reconciling live trading with paper trading and I believe the issue might come from limit orders.
On an hourly timeframe, I open a limit order when the OnOrderEvent of another order gets filled. It seems as if that order could be filled earlier in the hour it also gets instantly filled.
i.e. SPY opens at 310 at 13h00, at 13h25 SPY is at 308, triggering a limit order I put earlier. This causes my algo to open a take profit order at 309 which gets instantly filled in paper trading even though SPY never gets back to 309, since the high of the bar is 310.
From comparing orders of both live and paper trading this is what I believe to be the cause of the discrepancy, can anyone more knowledgeable about the code base comment?
Louis Clouatre
To clarify, a Limit Sell Order on SPY at 309 put in at 13h25 get's filled if the High of the hourly bar is over 309 even though SPY does not go over 309 from 13h25 to 14h00
Laurent Crouzet
Without reading the code, it is hard to be sure of the issue.
Could you just change the resolution from hourly to minutes, and see if that works again as it should?
Derek Melchin
Hi Louis,
The LEAN paper trading fill model fills orders with the latest bar. With this model, orders can't be filled during a bar.
The comment above mentions OnOrderEvent is called at 13:25, which is possible with IB Paper Trading. The IB Paper Trading model fills orders with the next high price and the order can be filled before the hour is up.
To resolve the issue, consider switching to LEAN paper trading.
Best,
Derek Melchin
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.
Louis Clouatre
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!