WebSocket

BrokerX WebSocket provides order placement, cancellation, modification, and server-pushed order and trade updates. After connecting, send LOGIN before any trading command.

Message format

Requests contain action, a caller-defined id, and args. Responses contain event, the echoed request id, code, message, and data. A response code of 0 means success; a nonzero code means failure. REST uses a different success code (200).

Login

URL

  • WebSocket private subscription channels: wss://brokerx-wss.connex.trade/v1/private

Sign this exact string using HMAC-SHA256 and encode the result as a hexadecimal digest:

message = timestamp + "GET" + "/users/self/verify"
sign = HMAC-SHA256(secretKey, message).hexdigest()

timestamp is a Unix timestamp in seconds. The server accepts a ±30-second window. Outside this window, login fails with 118001 WS_AUTH_FAILED.

{
  "action": "LOGIN",
  "id": "req-001",
  "args": {
    "apiKey": "YOUR_API_KEY",
    "timestamp": "1786673744",
    "sign": "YOUR_HMAC_SHA256_HEX_DIGEST"
  }
}

Generate a fresh timestamp and signature for each login. The sample timestamp is illustrative.

{
  "event": "LOGIN_ACK",
  "id": "req-001",
  "code": 0,
  "message": "success",
  "data": null
}

Trading commands sent before login return 118002 WS_PERMISSION_DENIED. After successful login, order changes and executions associated with the account are pushed automatically; no subscription request is required.

Commands and events

MessagePurpose
PLACE_ORDERPlace an order
CANCEL_ORDERCancel an order
REPLACE_ORDERModify an order
ORDER_UPDATEOrder status changes
TRADE_UPDATEExecutions

WebSocket errors

CodeNameMeaning
0-Success
118001WS_AUTH_FAILEDInvalid signature, unknown API key, or timestamp outside ±30 seconds
118002WS_PERMISSION_DENIEDNot logged in or portfolio lacks permission
112003ACCOUNT_NOT_FOUNDUnknown brokerClientId or no account mapping
113001ORDER_PLACE_FAILEDPlacement failed
113004ORDER_MODIFY_FAILEDModification failed
113005ORDER_CANCEL_FAILEDCancellation failed