Trade Event

OpenXSwitch - Webhook Trade Event

Webhooks for trade events notify you about the status of trade-related transactions within the OpenXSwitch system.

  • Parent Method: trade
  • Sub-Methods:
    • live: Triggered when a trade is created and actively ongoing.
    • cancelled: Triggered when a trade is cancelled before completion.
    • done: Triggered when a trade is fully executed.

Example Payload for Trade:

{
  "requestId": "ab67d4be56d4d549f59b92a17fd71b",
  "method": "trade.live",
  "params": {
    "id": "1234567890",
    "clientTxId": "client-tx-abc-123",
    "workspaceId": "656abf1e4b5f5e0012345678",
    "walletId": "656abf1e4b5f5e0098765432",
    "symbol": "TRXUSDT",
    "price": 0,
    "quantity": 1.5,
    "orderType": "limit",
    "side": "buy",
    "status": "live",
    "priceAvg": 44999.75,
    "base": {
      "baseCoin": "TRX",
    	"baseVolume": 0,
    },
    "quote": {
    	"quoteCoin": "USDT",
    	"quoteVolume": 0,
    },
    "fee": {
      "feeCoin": "TRX",
      "totalFee":  0,
    },
    "requestWindow": null,
    "cancelReason": null,
    "createdAt": "2025-05-12T08:30:00.000Z",
    "updatedAt": "2025-05-12T08:30:01.000Z",
    "completedAt": null,
    "wallet": {
      "id": "6812b103908d2d0d49c7ff79",
      "clientUserId": null,
      "email": "email@openxswitch.com",
      "name": "openxswitch-subwallet",
      "assets":[ 
          {
            "coin": "USDT",
            "balance": 9,
            "frozen": 0,
            "updatedAt": "2025-05-04T23:58:20.494Z"
          },
          {
            "coin": "TRX",
            "balance": 26.043,
            "frozen": 0,
            "updatedAt": "2025-05-04T23:58:20.494Z"
          }
      ],
      "isSubWallet": true
    }
  }
}
{
  "requestId": "ab67d4be56d4d549f59b92a17fd71b",
  "method": "trade.done",
  "params": {
    "id": "1234567890",
    "clientTxId": "client-tx-abc-123",
    "workspaceId": "656abf1e4b5f5e0012345678",
    "walletId": "656abf1e4b5f5e0098765432",
    "symbol": "TRXUSDT",
    "price": 45000.5,
    "quantity": 1.5,
    "orderType": "limit",
    "side": "buy",
    "status": "done",
    "priceAvg": 44999.75,
    "base": {
      "baseCoin": "TRX",
    	"baseVolume": 1.5,
    },
    "quote": {
    	"quoteCoin": "USDT",
    	"quoteVolume": 67499.63,
    },
    "fee": {
      "feeCoin": "USDT",
      "totalFee":  0.63,
    },
    "requestWindow": null,
    "cancelReason": null,
    "createdAt": "2025-05-12T08:30:00.000Z",
    "updatedAt": "2025-05-12T08:30:01.000Z",
    "completedAt":"2025-05-12T08:30:01.000Z",
    "wallet": {
      "id": "6812b103908d2d0d49c7ff79",
      "clientUserId": null,
      "email": "email@openxswitch.com",
      "name": "openxswitch-subwallet",
      "assets":[ 
          {
            "coin": "USDT",
            "balance": 9,
            "frozen": 0,
            "updatedAt": "2025-05-04T23:58:20.494Z"
          },
          {
            "coin": "TRX",
            "balance": 26.043,
            "frozen": 0,
            "updatedAt": "2025-05-04T23:58:20.494Z"
          }
      ],
      "isSubWallet": true
    }
  }
}
{
  "requestId": "ab67d4be56d4d549f59b92a17fd71b",
  "method": "trade.cancelled",
  "params": {
    "id": "1234567890",
    "clientTxId": "client-tx-abc-123",
    "workspaceId": "656abf1e4b5f5e0012345678",
    "walletId": "656abf1e4b5f5e0098765432",
    "symbol": "TRXUSDT",
    "price": 45000.5,
    "quantity": 1.5,
    "orderType": "limit",
    "side": "buy",
    "status": "cancelled",
    "priceAvg": 44999.75,
    "base": {
      "baseCoin": "TRX",
    	"baseVolume": 1.5,
    },
    "quote": {
    	"quoteCoin": "USDT",
    	"quoteVolume": 67499.63,
    },
    "fee": {
      "feeCoin": "USDT",
      "totalFee":  0.63,
    },
    "requestWindow": null,
    "cancelReason": "....",
    "createdAt": "2025-05-12T08:30:00.000Z",
    "updatedAt": "2025-05-12T08:30:01.000Z",
    "completedAt": null,
    "wallet": {
      "id": "6812b103908d2d0d49c7ff79",
      "clientUserId": null,
      "email": "email@openxswitch.com",
      "name": "openxswitch-subwallet",
      "assets":[ 
          {
            "coin": "USDT",
            "balance": 9,
            "frozen": 0,
            "updatedAt": "2025-05-04T23:58:20.494Z"
          },
          {
            "coin": "TRX",
            "balance": 26.043,
            "frozen": 0,
            "updatedAt": "2025-05-04T23:58:20.494Z"
          }
      ],
      "isSubWallet": true
    }
  }
}

Reference

FieldDescriptionType
requestIdUnique ID for the WebSocket requeststring
methodWebSocket method/event name (trade.live, ...)string
params.idUnique internal order IDstring
params.clientTxIdClient-supplied transaction IDstring
params.workspaceIdWorkspace ID associated with the tradestring
params.walletIdID of the wallet or sub-walletstring
params.symbolTrading pair symbol (e.g., TRXUSDT)string
params.priceOrder pricenumber
params.quantityQuantity (amount) placed in the ordernumber
params.orderTypeOrder type (limit, market)string
params.sideOrder side: buy or sellstring
params.statusTrade/order status (live, cancelled, done)string
params.priceAvgAverage price of filled amountnumber
params.base.baseCoinThe base coin being bought or soldstring
params.base.baseVolumeVolume of the base coinnumber
params.quote.quoteCoinThe quote coin (payment currency, e.g., USDT)string
params.quote.quoteVolumeVolume of the quote coin involvednumber
params.fee.feeCoinCoin in which the fee was charged, coin obtained from the transactionstring
params.fee.totalFeeTotal fee charged for the tradenumber
params.requestWindowTime window in unix milliseconds within which the request is valid.string
params.cancelReasonReason for cancellation (if applicable)string
params.createdAtISO timestamp when the order was createdstring (ISO)
params.updatedAtISO timestamp when the order was last updatedstring (ISO)
params.completedAtISO timestamp when the order was completed (if filled)string
params.wallet.idWallet ID (redundant with walletId, likely the master wallet ID)string
params.wallet.clientUserIdOptional external user identifier for the walletstring or null
params.wallet.emailEmail address associated with the walletstring
params.wallet.nameDisplay name of the walletstring
params.wallet.assetsList of assets and their balances after the tradearray of objects
params.wallet.assets[].coinCoin symbol (e.g., USDT, TRX)string
params.wallet.assets[].balanceBalance of the coin after the tradenumber
params.wallet.assets[].frozenFrozen amount of the coin (if any)number
params.wallet.assets[].updatedAtLast update time of the asset balancestring (ISO datetime)
params.wallet.isSubWalletWhether the wallet is a subwalletboolean