Order Pending-Cancel Events in Trading Systems
Summary
An order-pending-cancel event records that a trading system has dispatched a cancellation request and is waiting for the venue to acknowledge it. The event is applied to the order by the execution engine, updates the cache, and is published on the message bus. The typical state transition is from accepted to pending cancel, and a corresponding handler can be used by strategy code to respond to the event.
The document identifies three event fields beyond the common order-event data: the venue order identifier, which may be unavailable; the associated account identifier; and a flag indicating whether reconciliation generated the event. Its example shows a handler logging the client order identifier when cancellation becomes pending. This distinction matters because a cancellation request is not the same as confirmed cancellation: the order is still awaiting venue acknowledgement. The reference explains the event’s role and fields, but does not discuss venue-specific timing, failure handling, or trading performance.
Key ideas
- A pending-cancel event means a cancel request was sent and venue acknowledgement is outstanding.
- The usual order-state transition is from accepted to pending cancel.
- The execution engine applies the event, updates cached order state, and publishes it.
- The event includes venue order, account, and reconciliation information.
- A strategy handler can react to the event before cancellation is confirmed.
Tags
Full text
# OrderPendingCancel
# OrderPendingCancel
`OrderPendingCancel` represents a `CancelOrder` command having been sent to the trading
venue. The `ExecutionEngine` applies it to the order, updates the `Cache`, and publishes
it on the `MessageBus`. It fires when the system dispatches a cancel request and awaits
venue acknowledgement.
Typical transition: `ACCEPTED` -> `PENDING_CANCEL`. Handler: `on_order_pending_cancel`.
## Fields
Beyond the [common Python order event fields](index.md#common-python-order-event-fields),
`OrderPendingCancel` carries:
| Field | Python type | Required/default | Description |
| ---------------- | ------------------------ | ---------------- | ------------------------------------------------ |
| `venue_order_id` | `VenueOrderId` or `None` | `None` | The venue-assigned order identifier, if known. |
| `account_id` | `AccountId` or `None` | Required | 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_pending_cancel(self, event: OrderPendingCancel) -> None:
self.log.info(f"Cancel pending for {event.client_order_id}")
```
## 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.