Hello:
I am backtesting off-line (not in the cloud) and I see this.
20221123 17:58:04.478 ERROR:: MarketOnClose order and exchange not open.
I would think that the backtesting system does not care about the state of the exchange.
In any case the market is open. I do not appear to get any results.
My start and stop dates appear to be within the range of the local data.
It works if I run it in the cloud.
Thanks.
Bill
Louis Szeto
Hi Bill
A market on close order is only able to be placed when the market is still open, in which it will be filled at the market close time at that particular day. At 17:58:04.478 of 23 Nov 2022, the market for SPY is already closed, so the order was not valid. You might receive data like dividends during off-market hours, so it is better is you include an extra condition check to make sure the order is sent within market hour:
Check out the details/limitations in placing an MOC order in here.
Best
Louis
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.
Bill Crocker
Very good. Thanks.
Bill Crocker
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!