NautilusTrader
ConceptsEvents

Nightly docs

These docs track unreleased changes and may change without notice. Their code examples can use APIs that the latest release lacks, so run them with a development wheel or switch to the latest release docs.

OrderCancelRejected

OrderCancelRejected represents a CancelOrder command having been rejected by the trading venue. The ExecutionEngine applies it to the order, updates the Cache, and publishes it on the MessageBus. It fires when the venue rejects a cancel request.

Typical transition: PENDING_CANCEL -> previous status (for example ACCEPTED). Handler: on_order_cancel_rejected.

Fields

Beyond the common Python order event fields, OrderCancelRejected carries:

FieldPython typeRequired/defaultDescription
reasonstrRequiredThe order cancel rejection reason.
venue_order_idVenueOrderId or NoneNoneThe venue-assigned order identifier, if known.
account_idAccountId or NoneNoneThe account associated with the order, if known.
reconciliationboolRequiredIf generated during reconciliation.

Example

Reading the event in a strategy handler:

def on_order_cancel_rejected(self, event: OrderCancelRejected) -> None:
    self.log.warning(
        f"Cancel rejected for {event.client_order_id}: {event.reason}",
    )
  • Events - Event categories, dispatch, and the common order event fields.
  • Orders - Order types and the state machine.

On this page