The order during it’s life goes through the following states:
- None - the order has been created in the algorithm and has not been sent to the registration.
- Pending - the order has been sent to the registration
(ConnectorRegisterOrder(Order)) and the
ITransactionProviderNewOrder event for it has been called.
The confirmation of the order acceptance from the exchange is expected. If successful, the ConnectorOrderChanged,
event will be called and the order will be changed to the Active state.
Also the OrderId and OrderTime
properties will be initialized. In the case of the order rejection the ConnectorOrderRegisterFailed
event with the error description will be called and the order will be changed to the Failed state.
- Active - the order is active on exchange. Such order will be active as long as all of the order
OrderVolume volume is matched, or it will be forcibly cancelled through
ITransactionProviderCancelOrder(Order).
If the order matched partially the ITransactionProviderNewMyTrade
events about new trades on issued order have been called, as well as the ConnectorOrderChanged
event, which the OrderBalance notification about the order balance change passed.
The latest event will be arised in the case of the order cancellation.
- Done - the order is no longer active on the exchange (been fully matched
or cancelled).
- Failed - the order has not been accepted by the exchange (or intermediate
system, such as the broker server) for any reason.
To find out the order trading state (what volume is matched, whether the order fully matched, and so on) the
IsCanceled(Order),
IsMatchedEmpty(Order),
IsMatchedPartially(Order),
IsMatched(Order) and
GetMatchedVolume(Order)
methods should be used:
Order order = ....
Console.WriteLine(order.IsCanceled());
Console.WriteLine(order.IsMatched());
Console.WriteLine(order.IsMatchedPartially());
Console.WriteLine(order.IsMatchedEmpty());
Console.WriteLine(order.GetMatchedVolume());