# cancelByCloid - Cancel Orders by Client ID

Cancel orders using the client-assigned order ID (cloid) instead of the exchange-assigned order ID. This is useful for trading systems that track orders by their own identifiers.

## Sample Data

```json
{
  "signature": {
    "r": "0x2a0b6667955f197d530797576107b663fa08b20397286076f1684b3112738588",
    "s": "0x91a7dee6fae7c212e7b3f3a6dfbec5c555ac13986c56ec39bdc361b1713b8fb",
    "v": 28
  },
  "action": {
    "type": "cancelByCloid",
    "cancels": [
      {
        "asset": 159,
        "cloid": "0x00000000000007550096147985161351"
      },
      {
        "asset": 1,
        "cloid": "0x00000000000007580071223980263264"
      },
      {
        "asset": 5,
        "cloid": "0x00000000000007580071644980263273"
      }
    ]
  },
  "nonce": 1768146912996,
  "vaultAddress": "0x621c5551678189b9a6c94d929924c225ff1d63ab"
}
```

[View this transaction on Hypurrscan →](https://hypurrscan.io/tx/0x7aceda261c7a7d097c4804332644dc0202eb000bb77d9bdb1e978578db7e56f4)

## Field Reference

### Action Fields

| Field | Type | Description |
|-------|------|-------------|
| `type` | string | Always `"cancelByCloid"` |
| `cancels` | array | Array of cancel requests |

### Cancel Object Fields

| Field | Type | Description |
|-------|------|-------------|
| `asset` | number | Asset index of the order to cancel |
| `cloid` | string | Client order ID (hex string) assigned when order was placed |

### Optional Fields

| Field | Type | Description |
|-------|------|-------------|
| `vaultAddress` | string | Vault address if cancelling vault orders |
| `expiresAfter` | number | Timestamp after which the cancel request expires |

## Client Order ID Format

Client order IDs are 16-byte hex strings that you assign when placing orders. A common pattern encodes:

- Date/timestamp information
- Sequential counter
- System identifier

Example: `0x20260109000000000000000000150997`

- `20260109` - Date encoding (2026-01-09)
- `150997` - Sequence number

## Use Cases

### Trading System Integration

Use cloids to maintain order state without querying the exchange:

```python
def process_cancelByCloid_action(action):
    for cancel in action.get('cancels', []):
        asset = cancel['asset']
        cloid = cancel['cloid']

        # Match against your order management system
        order = order_tracker.get_by_cloid(cloid)
        if order:
            order.mark_cancelled()
```

### Order Lifecycle Tracking

Track orders from submission to cancellation using consistent identifiers across your systems.

### Latency Analysis

Compare timestamps between cancel request and block inclusion to measure execution latency.

## Related Action Types

- [order](https://www.dwellir.com/docs/hyperliquid/order) - Submit orders with cloid
- [cancel](https://www.dwellir.com/docs/hyperliquid/cancel) - Cancel by exchange order ID
- [modify](https://www.dwellir.com/docs/hyperliquid/modify) - Modify orders
