Trade Event Push Overview
WebSocket trade event push delivers real-time account-level trade notifications after the connection is established and authentication is complete. It is suitable for time-sensitive scenarios such as order status changes and fill status changes.
WebSocket Trade endpoint:
text
wss://webapi-trade.moomoo.comCapabilities
| Event Type | Description |
|---|---|
EVENT_NEW | Order placed successfully. The order has been accepted by the exchange or system. |
EVENT_REPLACED | Order modified successfully. The order price or quantity has been updated. |
EVENT_CANCELED | Order cancelled successfully. The order has been cancelled. |
EVENT_EXPIRED | Order expired. The order was cancelled by the system when its time-in-force expired. |
EVENT_FILL | Fill event. Covers both partial fills and full fills. |
EVENT_NEW_REJECTED | Order placement rejected. The order was rejected by the exchange or system. |
EVENT_REPLACE_REJECTED | Order modification rejected. The modification request was rejected; the original order is unchanged. |
EVENT_CANCEL_REJECTED | Order cancellation rejected. The cancellation request was rejected; the original order is unchanged. |
EVENT_FILL_CORRECT | Fill correction. An existing fill has been corrected. |
EVENT_FILL_CANCEL | Fill cancellation. An existing fill has been cancelled by the system. |
See Data Format for the full field reference of push messages.
Integration Flow
| Step | Description |
|---|---|
| 1. Establish connection | Connect to the WebSocket Trade endpoint wss://webapi-trade.moomoo.com. |
| 2. Authenticate | After the connection is established, complete authentication first. OAuth 2.1 + PKCE Bearer Token is recommended; traditional API Key is also supported. See Authentication. |
| 3. Receive events | Once authenticated, all trade events for the current user are pushed automatically — no explicit subscription request is needed. The server pushes JSON messages when trade events occur. See Subscription. |
| 4. Keep alive | Refresh the token periodically to maintain the connection and prevent disconnection due to token expiry. See Keep Alive. |
| 5. Reconnect on disconnect | When the connection drops, the client should reconnect and re-authenticate. Event push resumes automatically after reconnection. Do not assume events that occurred during the disconnect will be replayed. |
Important Constraints
- Authentication required: No events will be pushed until authentication is complete.
- No replay on reconnect: Trade events that occur while the connection is down will not be replayed after reconnection. Use REST APIs to query historical orders or fills if needed.
- Long connections need fault tolerance: Network switches, proxy timeouts, and server maintenance can all cause disconnections. Clients should implement reconnection and re-authentication.
- Event order is not guaranteed: In rare cases, network jitter may cause events to arrive out of order. Do not rely solely on push order to drive state machines.
Next Steps
- Authentication — Learn about the authentication flow after establishing a WebSocket connection.
- Subscription — Learn about the subscription model and event coverage.
- Keep Alive — Learn about heartbeats, timeouts, and reconnection handling.
- Data Format — View the push message structure, event types, and field reference.
- Error Codes — Troubleshoot authentication and connection errors.