Last updated

Trade Websocket API

This endpoint is used for order managements.

Authorization

To use the trade websocket api you must connect with the Authorization header set to your apikey.

"Authorization": "YOURAPIKEY"

Connect websocket to https://api.hibachi.xyz/ws/trade?accountId={YOUR_ACCOUNT_ID}

Usage

The server will reply with exactly one message for each request you send.

The request and response format will be identical to the REST API: /trade/order and /trade/orders.

Optional WS Query Parameters

  • accountId
Supported methods
  • order.place
  • order.cancel
  • order.modify
  • order.status
  • orders.status

Order Place

Request Body

{
    "id": 123,
    "method": "order.place",
    "params": {
        "accountId": 273,
        "symbol": "ETH/USDT-P",
        "orderType": "LIMIT",
        "side": "BID",
        "quantity": "0.01",
        "price": "2345.01",
        "nonce": 1714701600000000,
        "maxFeesPercent": "0.00045",
        "orderFlags": "POST_ONLY"
    },
    "signature": "0000000000000000000000000000000000000000000000000000000000000000"
}

Response Body

{
    "id": "<accountId>",
    "result": {
        "orderId": 578721673790138368
    },
    "status": 200
}

Order Cancel

Request Body

{
    "id": 123,
    "method": "order.cancel",
    "params": {
        "orderId": 578404507400316928,
        "accountId": <accountId>,
        "nonce": 1714701600000000
    },
    "signature": "0000000000000000000000000000000000000000000000000000000000000000"
}

Response Body

{
    "id": 123,
    "status": 200
}

Order Modify

Request Body

{
    "id": 123,
    "method": "order.modify",
    "params": {
        "orderId": "586504376442422272",
        "accountId": 273,
        "symbol": "ETH/USDT-P",
        "quantity": "0.998",
        "price": "2228.3",
        "maxFeesPercent": "0.00045",
        "nonce": 1
    },
    "signature": "0000000000000000000000000000000000000000000000000000000000000000"
}

Response Body

{
    "id": 123,
    "status": 200
}

Order Status

Request Body

{
    "id": 123,
    "method": "order.status",
    "params": {
        "orderId": "578744951878232075",
        "accountId": <accountId>
    }
}

Response Body

{
    "id": 123,
    "result": {
        "accountId": 128,
        "availableQuantity": "8689.981394",
        "orderId": 578744951878232075,
        "orderType": "LIMIT",
        "price": "0.230104060",
        "side": "BID",
        "status": "PENDING",
        "symbol": "DDNG/USDT-P",
        "totalQuantity": "8689.981394"
    },
    "status": 200
}

Orders Status

Request Body

{
    "id": 124,
    "method": "orders.status",
    "params": {
        "accountId": 273
    }
}

Response Body

{
    "id": 123,
    "result": [
        {
            "accountId": 128,
            "availableQuantity": "0.0856034087",
            "orderId": 578744886208014338,
            "orderType": "LIMIT",
            "price": "70048.61242",
            "side": "BID",
            "status": "PENDING",
            "symbol": "BTC/USDT-P",
            "totalQuantity": "0.0856034087"
        },
        {
            "accountId": 128,
            "availableQuantity": "4.538826542",
            "orderId": 578744886209849345,
            "orderType": "LIMIT",
            "price": "3530.780445",
            "side": "ASK",
            "status": "PENDING",
            "symbol": "ETH/USDT-P",
            "totalQuantity": "4.538826542"
        }
    ],
    "status": 200
}

Orders Cancel

Request Body

{
    "id": 123,
    "method": "orders.cancel",
    "params": {
        "accountId": <accountId>,
        "nonce": "<nonce>",
        "contractId": 1 // optional, if use it is canceling all orders for the contract
    },
    "signature": "0000000000000000000000000000000000000000000000000000000000000000"
}

Response Body

{
    "id": 123,
    "status": 200
}

Orders Batch

Request Body

{ 
    "accountId": <accountId>, 
    "method": "orders.batch",
    "params": {
        "accountId": 126,
        "orders": [
            {
                "action": "place",
                "nonce": 1714701600000000,
                "symbol": "ETH/USDT-P",
                "orderType": "LIMIT",
                "side": "BID",
                "quantity": "1.01",
                "price": "3500.1",
                "maxFeesPercent": "0.00045",
                "signature": "0000000000000000000000000000000000000000000000000000000000000000"
            },
            {
                "action": "modify",
                "orderId": "578721673790138369",
                "nonce": 1714701600000002,
                "updatedQuantity": "0.1",
                "updatedPrice": "3500.1",
                "maxFeesPercent": "0.00045",
                "signature": "0000000000000000000000000000000000000000000000000000000000000000"
            }, 
            {
                "action": "cancel",
                "orderId": "578721673790138370",
                "signature": "0000000000000000000000000000000000000000000000000000000000000000"
            }
        ]
    }
}

Response Body

{
    "id": 123,
    "status": 200
}