Handling Rejected Order Cancellation Events
Summary
This documentation describes an order event raised when a trading venue refuses a cancellation request. The execution engine applies the event to the order, updates the cache, and publishes it through the message bus. A typical state change moves an order out of pending-cancel status and back to its prior status, such as accepted. Strategies can handle the event to record or respond to the rejection.
The event includes a required rejection reason and reconciliation flag, along with optional venue order and account identifiers when available. These fields help identify the affected order, understand why cancellation failed, and distinguish events produced during reconciliation. The example demonstrates logging the client order identifier and rejection reason, but the document does not prescribe a recovery policy. A strategy may need to account for the order remaining active or otherwise check its current state before taking follow-up action. This is operational guidance for order lifecycle handling, not a trading signal or performance analysis.
Key ideas
- A cancellation rejection means the venue declined a cancel request.
- The order typically returns from pending-cancel to its previous state.
- The event carries a required reason and reconciliation flag, with optional venue and account identifiers.
- A strategy can handle the event to log the reason and decide how to manage the order afterward.
Tags
Full text
# OrderCancelRejected
# 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](index.md#common-python-order-event-fields),
`OrderCancelRejected` carries:
| Field | Python type | Required/default | Description |
| ---------------- | ------------------------ | ---------------- | ------------------------------------------------ |
| `reason` | `str` | Required | The order cancel rejection reason. |
| `venue_order_id` | `VenueOrderId` or `None` | `None` | The venue-assigned order identifier, if known. |
| `account_id` | `AccountId` or `None` | `None` | The account associated with the order, if known. |
| `reconciliation` | `bool` | Required | If generated during reconciliation. |
## Example
Reading the event in a strategy handler:
```python
def on_order_cancel_rejected(self, event: OrderCancelRejected) -> None:
self.log.warning(
f"Cancel rejected for {event.client_order_id}: {event.reason}",
)
```
## Related guides
- [Events](index.md) - Event categories, dispatch, and the common order event fields.
- [Orders](../orders/) - Order types and the state machine.Shown in full with attribution under the source's licence. Licence: LGPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.