# Trade Interface

# 1. Place a New Order

HTTP Requests

    # Request
    POST api/v1/user/trade

Request Method

POST

Request Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms
side String YES (Bid/Ask)
entrustPrice float64 YES Price
entrustVolume float64 YES Volume
tradeType String YES Market/Limit
action String YES Open/Close

Return Parameters

Parameters Type Field Description
orderId String Order ID
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
            "orderId": "11141",
        }
    }

# 2. One-Click Close Position

After querying the position information, you can close the position by one-click based on the position ID. Please note that the one-click closed position is traded at market price.

HTTP Requests

	# Request
    POST api/v1/user/oneClickClosePosition

Request Method

POST

Request Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
positionId Int64 YES ID of the position needs to be closed with one click
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Description
code Int64 error code, 0 means successfully response, others means response failure
msg String Error Details Description
orderId String Order ID generated by one-click close
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
        }
    }

# 3. One-Click Close All Positions

Close all positions within the current account by one click. Please note that the one-click closed positions are traded at market price.

HTTP Requests

	# Request
    POST api/v1/user/oneClickCloseAllPositions

Request Method

POST

Request Parameters

Parameters Type Required Description
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Description
code Int64 error code, 0 means successfully response, others means response failure
msg String Error Details Description
orders String array Multiple Order IDs generated by one-click close all
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
          "orders": ["123", "456", "789"]
        }
    }

# 4. Cancel an Order

   Cancel an order that is currently in a unfilled state

HTTP Requests

    # Request
    POST api/v1/user/cancelOrder

Request Method

POST

Request Parameters

Parameters Type Required Description
orderId String YES Order ID
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Field Description
orderId String Order ID
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
            "orderId": "11141",
        }
    }

# 5. Cancel a Batch of Orders

Cancel a batch of orders that are currently in a unfilled state

HTTP Requests

	# Request
    POST api/v1/user/batchCancelOrders

Request Method

POST

Request Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Description
code Int64 error code, 0 means successfully response, others means response failure
msg String Error Details Description
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
        }
    }

# 6. Cancel All Orders

Cancel all orders that are currently in a unfilled state

HTTP Requests

	# Request
    POST api/v1/user/cancelAll

Request Method

POST

Request Parameters

Parameters Type Required Description
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Description
code Int64 error code, 0 means successfully response, others means response failure
msg String Error Details Description
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
        }
    }

# 7. Unfilled Order Acquisition

Query the details of unfilled orders within the current account over a certain period of time

HTTP Requests

    # Request
    POST api/v1/user/pendingOrders

Request Method

POST

Request Parameters

Name Type Required Field Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT; Return all if the field is null.
apiKey String YES
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Description
entrustTm String Trigger time of order
side String Direction (Bid/Ask)
tradeType String Order Type(Market/Limit)
action String Open/Close
entrustPrice Float64 Order Price
entrustVolume Float64 Order Amount
avgFilledPrice Float64 Ave. Price
filledVolume Float64 Filled Amount
orderId String Order ID

# Response
   {
      "code": 0,
      "msg": "",
      "data": {
           "orders": [
               {
                   "entrustTm": "2018-04-25T15:00:51.000Z",
                   "side": "Bid",
                   "tradeType": "Limit",
                   "action": "Open",
                   "entrustPrice": 6.021954,
                   "entrustVolume": 18.098,
                   "filledVolume": 0,
                   "avgFilledPrice": 0,
                   "orderId": "6030",
                   "symbol": "BTC-USDT",
               },
               {
                   "entrustTm": "2018-04-25T15:00:51.999Z",
                   "side": "Ask",
                   "tradeType": "Limit",
                   "action": "Close",
                   "entrustPrice": 6.021954,
                   "entrustVolume": 18.098,
                   "filledVolume": 0,
                   "avgFilledPrice": 0,
                   "orderId": "6030",
                   "symbol": "ETH-USDT",
               },
           ]
       }
   }

# 8. Query Order Details

HTTP Requests

 # Request
 POST api/v1/user/queryOrderStatus

Request Method

POST

Request Parameters

Parameters Type Required Description
apiKey String YES Interface Key
timestamp String YES Timestamp of initiating the request, unit: ms
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
orderId String YES Order ID

Return Parameters

Parameters Type Description
entrustTm String Order Time
side String Direction (Bid/Ask)
tradeType String Order type (Market/Limit)
action String Open/Close
entrustPrice Float64 Order Price
entrustVolume Float64 Order Amount
avgFilledPrice Float64 Ave. Price
filledVolume Float64 Filled Amount
orderId String Order No.
status String The status of Order (Filled or PartiallyFilled, Pending, Cancelled, Failed)

Remarks

Status Field Description
Pending Order that has not been closed
PartiallyFilled Order that has been Partially filled
Cancelled Cancelled
Filled Filled
Failed Failed
# Response
{
    "code": 0,
    "msg": "",
    "data": {
        "entrustTm": "2018-04-25T15:00:51.000Z",
        "side": "Ask",
        "tradeType": "Limit",
        "action": "Close",
        "entrustPrice": 6.021954,
        "entrustVolume": 18.098,
        "filledVolume": 0,
        "avgFilledPrice": 0,
        "orderId": "6030",
        "status": "Filled"
 	}
 }

# 9. Switch Margin Mode

Switch the margin mode of the Perpetual Swap Account, Cross Margin mode or Isolated Margin mode.

HTTP Requests

	# Request
    POST api/v1/user/setMarginMode

Request Method

POST

Request Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
marginMode String YES Isolated or Cross
apiKey String YES Interface key
timestamp String YES Timestamp of initiating the request, unit: ms

Return Parameters

Parameters Type Description
code Int64 error code, 0 means successfully response, others means response failure
msg String Error Details Description
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
        }
    }

# 10. Switch Leverage

Switch the leverage size of a certain trading pair for long or short positions

HTTP Requests

	# Request
  	POST api/v1/user/setLeverage

Request Method

POST

Request Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
side String YES Leverage of Long or Short positions
leverage String YES Leverage Size
apiKey String YES Interface key
timestamp String YES Timestamp of initiating the request, unit: ms
```javascript
    # Response
        {
            "code": 0,
            "msg": "",
            "data": {
                "userId": "123",
                "currency": "USDT",
                "balance": 123.33,
                "equity": 128.99,
                "unrealisedPNL": 1.22,
                "realisedPNL": 8.1,
                "availableMargin": 123.33,
                "usedMargin": 2.2,
                "freezedMargin": 3.3,
                "longLeverage": 10,
                "shortLeverage": 10,
            }
        }
```

Return Parameters

Parameters Type Description
code Int64 error code, 0 means successfully response, others means response failure
msg String Error Details Description
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
        }
    }

# 11. User's Force Orders

HTTP Requests

    # Request
    POST api/v1/user/forceOrders

Request Method

POST

Request Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
autoCloseType String YES "LIQUIDATION" for liquidation orders, "ADL" for ADL orders.
lastOrderId int64 YES Used for paging, fill in 0 for the first time; for subsequent requests, fill in the last order id from the previous return results.
length int64 YES Length per request, max 100

Return Parameters

Parameters Type Description
symbol String Trading pair symbol
tradeType String Order type, Limit or Market
action String "LIQUIDATION" for liquidation orders, "ADL" for ADL orders.
avgFilledPrice Float64 Average filled price
entrustTm String Entrust time
filledVolume Float64 Filled volume
orderId String Order No.
side String Direction (Bid/Ask)
profit Float64 P&L
commission Float64 Fees
# Response
    {
        "code": 0,
        "msg": "",
        "data": {
        	"symbol": "BTC-USDT",
        	"tradeType": "Limit",
        	"action": "Liquidation",
        	"avgFilledPrice": 5938.23,
        	"entrustTm": "2018-04-25T15:00:51.000Z",
        	"filledVolume": 1.2123,
        	"orderId": 123456789,
        	"side": "Bid",
        	"profit": -11.34,
        	"commission": 0.4231
        }
    }

Remarks


[BingX]: https://bingx.com
[English Docs]: https://bingx.com
[Unix Epoch]: https://en.wikipedia.org/wiki/Unix_time

Last Updated: 12/2/2021, 2:37:08 PM