I understand:
- When an algorithm uses daily resolution, the data becomes available at 16:00 (close)
- When a market order is placed after hours, LEAN converts it to a Market On Open order
This makes sense. But I struggle to reconcile this for live trading vs. backtest. In backtesting, are the fills recorded same day at 16:00, or following morning at 09:31?
‘Orders’ tab of my backtests appear to show 16:00 (which would use closing prices), but then if I deploy to live trading and the trades are now made following morning at 09:31 from resulting MOO order, this would create a HUGE discrepancy for live trading that isn't modelled in backtesting if the trades are now taken the morning after when the signal is generated…
Key data used in my algorithm is only available in daily resolution (VIX, VIX3M, VIX6M etc) which means I cannot select a denser resolution and consolidate, so if this is the case, I am lost as to how I can ensure orders fill same day.
Desired outcome is having orders filled at market close, same moment OnData() fires, using all daily resolution.
Any help is appreciated :)
Mia Alissi
To address discrepancies between backtesting and live trading with daily resolution, consider the following:
Order Fill Timing:
MarketOrder
, occur at the close price on the same day at 16:00.Market On Open
(MOO), potentially causing discrepancies if the market opens at a different price.Use of Market On Close (MOC) Orders:
Market On Close
(MOC) orders, ensuring deterministic execution at the closing price.Asynchronous Order Monitoring:
on_order_event
to handle order state changes in real-time, adapting your strategy based on executions.Testing and Alignment:
Sources: Key Concepts - QuantConnect.com, Trading and Orders - QuantConnect.com, Data Preparation - QuantConnect.com, Opening Range Breakout for Stocks in Play, US Equities - 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.
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!