Shioaji uses order_deal_event to push active order and deal events (accepted, updated, cancelled, or filled) immediately after actions like place_order, update_order, or cancel_order.
Key distinctions:
order_deal_event: Real-time active pushes. Use these for live trading logic.order_deal_records: Historical/reconciliation queries. Use these for auditing or recovery.- Race Condition: Deal events (fills) may arrive before order events due to exchange message priority. Always match events using
order.id or status.id against the deal's trade_id. - Success Check: For order operations, check if
operation.op_code == "00". Any other value indicates failure, and the error details are in operation.op_msg.
| Event state | Meaning | Python callback payload | HTTP SSE payload |
|-------------|---------|-------------------------|-----------------|
| `OrderState.StockOrder` / `SORDER` | Stock order accepted/updated/cancelled | dict-like event with `operation`, `order`, `status`, `contract` | `{"state":"StockOrder","data":{"StockOrder":{...}}}` |
| `OrderState.StockDeal` / `SDEAL` | Stock deal / partial fill / fill | dict-like event with `trade_id`, `seqno`, `ordno`, `exchange_seq`, `broker_id`, `account_id`, `action`, `code`, `order_cond`, `order_lot`, `price`, `quantity`, `web_id`, `custom_field`, `ts` | `{"state":"StockDeal","data":{"StockDeal":{...}}}` |
| `OrderState.FuturesOrder` / `FORDER` | Futures/options order accepted/updated/cancelled | dict-like event with `operation`, `order`, `status`, `contract` | `{"state":"FuturesOrder","data":{"FuturesOrder":{...}}}` |
| `OrderState.FuturesDeal` / `FDEAL` | Futures/options deal / partial fill / fill | dict-like event with `trade_id`, `seqno`, `ordno`, `exchange_seq`, `broker_id`, `account_id`, `action`, `code`, `price`, `quantity`, `subaccount`, `security_type`, `delivery_month`, `full_code`, `strike_price`, `option_right`, `market_type`, `combo`, `ts` | `{"state":"FuturesDeal","data":{"FuturesDeal":{...}}}` |