Trading and Orders

Order Events


An OrderEvent object represents an update to the state of an order. As the state of your orders change, we notify your algorithm with OrderEvent objects through the OnOrderEvent and OnAssignmentOrderEvent event handlers.

Order States

Orders can have any of the following states:

Event Attributes

The OnOrderEvent and OnAssignmentOrderEvent event handlers in your algorithm receive OrderEvent objects, which have the following attributes:

Track Order Events

Each order generates events over its life as its status changes. Your algorithm receives these events through the OnOrderEvent and OnAssignmentOrderEvent methods. The OnOrderEvent event handler receives all order events. The OnAssignmentOrderEvent receives order events for Option assignments. The event handlers receive an OrderEvent object, which contains information about the order status.

public override void OnOrderEvent(OrderEvent orderEvent)
    var order = Transactions.GetOrderById(orderEvent.OrderId);
    if (orderEvent.Status == OrderStatus.Filled)
        Debug($"{Time}: {order.Type}: {orderEvent}");

public override void OnAssignmentOrderEvent(OrderEvent assignmentEvent)
def OnOrderEvent(self, orderEvent: OrderEvent) -> None:
    order = self.Transactions.GetOrderById(orderEvent.OrderId)
    if orderEvent.Status == OrderStatus.Filled:
        self.Debug(f"{self.Time}: {order.Type}: {orderEvent}")

def OnAssignmentOrderEvent(self, assignmentEvent: AssignmentEvent) -> None:

To get a list of all OrderEvent objects for an order, call the OrderEvents method of the order ticket.

var orderEvents = orderTicket.OrderEvents();
order_events = order_ticket.OrderEvents()

If you don't have the order ticket, get the order ticket from the TransactionManager.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: