I am opening the order in synchronous mode. I check the OrderStatus immediately after opening the order, and again when I receive an OrderEvent.
Would it be New or Submitted? Or first one and then the other? If both, will there be an OrderEvent when it transitions from one to the other?
I assume it will eventually be Filled (and an OrderEvent will occur) if/when it it triggered/filled.
Thanks.
Mia Alissi
When you place an order, it initially has the
OrderStatus.New
status. This status represents a new order pre-submission to the order processor. After the order is submitted to the market, its status changes toOrderStatus.Submitted
.The
OnOrderEvent
method in your algorithm receivesOrderEvent
objects, which notify the algorithm of new orders and changes in the order status such as fill events and cancellations. Therefore, you should receive anOrderEvent
when the order transitions fromNew
toSubmitted
.If the order is filled, its status will change to
OrderStatus.Filled
, and anOrderEvent
will be triggered.Here is an example of how you can handle order events in Python:
In this example, the
OnOrderEvent
method logs the order type and event details if the order status isFilled
.Remember, in live trading, order events are triggered asynchronously as they occur. To avoid infinite loops, it's recommended not to place orders in the
OnOrderEvent
method.For more information, you can refer to the Order Events section in the QuantConnect documentation.
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.
Lee Allen
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!