WebSocket is a new protocol for HTML5, which enables full-duplex communication between the client and the server, allowing data to travel in both directions quickly. The client and server connections can be established through a simple handshake, and the server can actively push information to the client according to the business rules. The advantages are as follows:
When the client and the server perform data transmission, the request header information is relatively small, about 2 bytes.
Both the client and the server can actively send data to the other party.
There is no need to create TCP requests and destroy multiple times, saving bandwidth and server resources.
NOTE For Market Orders, you need to set orderType as Market.
You can get contract price and quantity precision configuration data in the exchange endpoint.
Note: if your balance does not meet the margin requirement (which is the minimum margin requirement + open position fee + close position fee), "insufficient balance" error message will be returned.
Expiration milliseconds, usually set to the current time plus 10 seconds
signature
string
YES
--
signature=sha256(apiSecret+method+path+expires)Note: The + needs to be removed to generate a signature
## Order
symbol
string
YES
--
The contract symbol, eg: BTCUSDT
side
string
YES
--
Direction of the order. Direction type: Buy, Sell
orderType
string
YES
--
The order type, includes: Limit, Market
currency
string
YES
--
Currency of account, eg: BTC, ETH, USDT
qty
double
YES
0
The number of contracts to buy, Positive integer, 1Qty=1USDT
openPosition
boolean
YES
true
Open position or Close position order, eg: true or false
positionId
string
NO
--
The position ID,In the split-warehouse mode, closing a position requires, eg: 1323056886107491328-CCF-USDT-XRPUSDT-Long
price
double
NO. REQUIRED for (Limit) orders
--
Order price
triggerPrice
double
NO
--
Trigger price for conditional order
trailingStop
double
NO
--
Trailing stop value for advanced order, conflict with stopLossPrice
stopLossPrice
double
NO
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
NO
--
Stop win price for advanced order
tif
string
NO
GOOD_TILL_CANCEL
Type of advanced order, Available values : FILL_OR_KILL, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, QUEUE_OR_CANCEL
triggerType
string
NO
--
Trigger type of price for conditional order, eg: LAST or INDEX, it will be LAST if not providedAvailable values : INDEX, LAST, MARK
stopWinType
string
NO
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
clientOrderId
string
NO
--
An unique ID for the order (user defined), Must satisfy regular: ^[\.A-Z\:/a-z0-9_-]{1,36}$"
created
long
1570759718825
Timestamp when the order is created
modified
long
1551062936784
Timestamp when this order was updated last time
id
string
O101-20230531-025722-174-1016
The order ID
clientOrderId
string
213443
An unique order ID which is defined by user
symbol
string
BTC-PERP-REV
The contract symbol
price
float
8200
The order price
qty
float
1.01
Order quantity
cumQty
float
1.01
The number of orders that has been executed
avgPx
float
4754.24
Average price of filled orders
side
string
--
Direction of the order. Direction type: Buy, Sell
type
string
--
The order type, includes: LIMIT, Market
tif
string
GTC
Type of advanced order, Available values : FILL_OR_KILL, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, QUEUE_OR_CANCEL
fee
double
--
Fees incurred for this order.
orderId
string
O101-20230531-025722-174-1016
NO
The order ID
clientOrderId
string
O101-20230531-025722-174-1016
NO
An unique order ID which is defined by user
id
string
O101-20230531-025722-174-1016
The order ID
uid
string
1323056886107491328
The User ID
symbol
string
BTCUSDT
The contract symbol
created
long
1570759718825
Timestamp when the order is created
modified
long
1551062936784
Timestamp when this order was updated last time
clientOrderId
string
213443
An unique order ID which is defined by user
side
string
--
Direction of the order. Direction type: Buy, Sell
type
string
--
The order type, includes: LIMIT, Market
tif
string
GTC
Type of advanced order, Available values : FILL_OR_KILL, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, QUEUE_OR_CANCEL
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
price
double
8200
The order price
qty
double
11.0
Order quantity
openPosition
boolean
true
Open position or Close position order, eg: true or false
ordStatus
boolean
true
Open position or Close position order, eg: true or false
cumQty
double
11.0
The number of orders that has been executed
avgPx
double
4754.24
Average price of filled orders
ordStatus
string
FILLED
The order status, includes: PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELED, REJECTED, PENDING_REPLACE, REPLACED, WAITING
iceberg
boolean
false
The order is iceberg
showQty
double
1.0
The order showQty
pnl
double
1.1
Pnl incurred for this order.
fee
double
1.1
Fees incurred for this order.
triggerPrice
double
--
Trigger price for conditional order
triggerType
string
--
Trigger type of price for conditional order, eg: LAST or INDEX, it will be LAST if not providedAvailable values : INDEX, LAST, MARK
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
stopLossPrice
double
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
--
Stop win price for advanced order
stopWinType
string
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
prevTimeMillis
long
1685505879000
NO
The order created, Query the data from the prevTimeMillis to the current time
id
string
O101-20230531-025722-174-1016
The order ID
uid
string
1323056886107491328
The User ID
symbol
string
BTCUSDT
The contract symbol
created
long
1570759718825
Timestamp when the order is created
modified
long
1551062936784
Timestamp when this order was updated last time
clientOrderId
string
213443
An unique order ID which is defined by user
side
string
--
Direction of the order. Direction type: Buy, Sell
type
string
--
The order type, includes: LIMIT, Market
tif
string
GTC
Type of advanced order, Available values : FILL_OR_KILL, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, QUEUE_OR_CANCEL
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
price
double
8200
The order price
qty
double
11.0
Order quantity
openPosition
boolean
true
Open position or Close position order, eg: true or false
ordStatus
boolean
true
Open position or Close position order, eg: true or false
cumQty
double
11.0
The number of orders that has been executed
avgPx
double
4754.24
Average price of filled orders
ordStatus
string
FILLED
The order status, includes: PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELED, REJECTED, PENDING_REPLACE, REPLACED, WAITING
iceberg
boolean
false
The order is iceberg
showQty
double
1.0
The order showQty
pnl
double
1.1
Pnl incurred for this order.
fee
double
1.1
Fees incurred for this order.
triggerPrice
double
--
Trigger price for conditional order
triggerType
string
--
Trigger type of price for conditional order, eg: LAST or INDEX, it will be LAST if not providedAvailable values : INDEX, LAST, MARK
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
stopLossPrice
double
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
--
Stop win price for advanced order
stopWinType
string
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
orderId
string
O101-20230531-025722-174-1016
YES
The order ID
id
string
T101-20230531-040439-548-1608
The trade ID
symbol
string
BTCUSDT
The contract symbol
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
orderId
string
O101-20230531-025722-174-1016
The order ID
side
string
--
Direction of the order. Direction type: Buy, Sell
openPosition
boolean
true
Open position or Close position order, eg: true or false
userId
string
1323056886107491328
The user id
accountId
string
1323056886107491328
The account id
price
double
8200
The trade price
qty
double
11.0
Order quantity
fee
double
1.1
Fees incurred for this order.
feeRate
double
0.0002
Fee rate
createdTimestamp
long
1570759718825
Timestamp when the order is created
symbol
long
BTCUSDT
NO
Retrieve active orders of symbol, eg: BTCUSDT; Will return all active orders of user if empty
id
string
O101-20230531-025722-174-1016
The order ID
uid
string
1323056886107491328
The User ID
symbol
string
BTCUSDT
The contract symbol
created
long
1570759718825
Timestamp when the order is created
modified
long
1551062936784
Timestamp when this order was updated last time
clientOrderId
string
213443
An unique order ID which is defined by user
side
string
--
Direction of the order. Direction type: Buy, Sell
type
string
--
The order type, includes: LIMIT, Market
tif
string
GTC
Type of advanced order, Available values : FILL_OR_KILL, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, QUEUE_OR_CANCEL
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
price
double
8200
The order price
qty
double
11.0
Order quantity
openPosition
boolean
true
Open position or Close position order, eg: true or false
ordStatus
boolean
true
Open position or Close position order, eg: true or false
cumQty
double
11.0
The number of orders that has been executed
avgPx
double
4754.24
Average price of filled orders
ordStatus
string
FILLED
The order status, includes: PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELED, REJECTED, PENDING_REPLACE, REPLACED, WAITING
iceberg
boolean
false
The order is iceberg
showQty
double
1.0
The order showQty
pnl
double
1.1
Pnl incurred for this order.
fee
double
1.1
Fees incurred for this order.
triggerPrice
double
--
Trigger price for conditional order
triggerType
string
--
Trigger type of price for conditional order, eg: LAST or INDEX, it will be LAST if not providedAvailable values : INDEX, LAST, MARK
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
stopLossPrice
double
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
--
Stop win price for advanced order
stopWinType
string
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
positionId
string
--
The position ID, eg: 1323056886107491328-CCF-USDT-XRPUSDT-Long
orderId
integer
NO
--
The order ID
clientOrderId
string
NO
--
Unique customized client ID for the order
result
integer
O101-20230531-023520-732-0610
The order ID or An unique order ID defined by client
symbol
string
YES
--
The contract symbol, eg: BTCUSDT
side
string
YES
--
Position side, eg: Long or Short
currency
string
YES
--
Currency of account, eg: BTC, ETH, USDT
------------
------------
------------
------------
------------
uid
string
1323056886107491328
The User ID
id
string
1323056886107491328-CCF-ETH-ETHUSDT-Short
The position ID
lvg
double
10.0
The position lever
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
symbol
string
BTCUSDT
The contract symbol
side
string
--
Direction of the position. Direction type: Long, Short
qty
double
11.0
Position quantity
price
double
4754.24
Price of position
closableQty
double
11.0
Closable quantity
pnlRate
double
-0.001
Pnl rate
value
double
11.0
Position value by currency
positionLeverage
double
11.0
Position leverage
liquidationPrice
double
11.0
Liquidation price
pnl
double
1.1
Realized pnl
urPnL
double
1.1
Unrealized pnl
deposit
double
1.1
deposit
lastPrice
double
1.1
Last price
created
long
1570759718825
Timestamp when the position is created
trailingStopPrice
double
--
Trailing stop price
stopLossPrice
double
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
--
Stop win price for advanced order
stopWinType
string
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
twoSidePosition
boolean
YES
--
Switch to two side position mode if true, otherwise, switch to one side position mode
currency
string
YES
--
Currency of account, eg: BTC, ETH, USDT
------------
------------
------------
------------
individual
boolean
YES
--
Position mode, true -> Individual; false -> Cross
currency
string
YES
--
Currency of account, eg: BTC, ETH, USDT
------------
------------
------------
------------
leverage
double
YES
--
Position leverage
symbol
string
YES
--
The contract symbol, eg: BTCUSDT
currency
string
YES
--
Currency of account, eg: BTC, ETH, USDT
------------
------------
------------
------------
symbol
string
YES
--
The contract symbol, eg: BTCUSDT
currency
string
YES
--
Currency of account, eg: BTC, ETH, USDT
side
string
YES
--
Position side, eg: Long or Short
positionId
string
YES
--
The position ID, eg: 1323056886107491328-CCF-USDT-XRPUSDT-Long
addDeposit
double
NO
--
Increase or decrease extra deposit for individual position
stopLossPrice
double
NO
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
NO
--
Stop win price for advanced order
stopWinType
string
NO
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
NO
--
Trailing stop value for advanced order, conflict with stopLossPrice
------------
------------
------------
------------
uid
string
1323056886107491328
User id
currency
string
USDT
currency
cash
double
0.01215991
cash
withdrawableCash
double
0
Withdrawable cash
frozenCash
double
0
Frozen cash
urPnl
double
0
Unrealized pnl
cashAvailable
double
0
Available cash
uid
string
1323056886107491328
User id
currency
string
USDT
currency
twoWayPosition
boolean
true
Two way position
individualPosition
boolean
false
Individual position
multiPosition
boolean
false
false means closed positions, true means split positions
op
string
YES
login
Operation event login
txId
string
YES
--
txId is a unique string, format: TXyyyyMMdd-HHmmss-ms-serial number, TX year-month-day-hour-minute-second-millisecond-unique serial number, for example TX20220809-142413-671-1
apiKey
string
YES
--
Apply at the individual center, apikey/apiSecret
expires
long
YES
--
Expiration milliseconds, usually set to the current time plus 10 seconds
signature
string
YES
--
signature=sha256(apiSecret+method+path+expires)Note: The + needs to be removed to generate a signature
txId
string
TX20200317-133934-511-458
txId is a unique string, format: TXyyyyMMdd-HHmmss-ms-serial number, TX year-month-day-hour-minute-second-millisecond-unique serial number, for example TX20220809-142413-671-1
op
string
YES
--
subscribe/unsubscribe
channel
string
YES
channel
Event name
apiKey
string
YES
--
Apply at the individual center, apikey/apiSecret
expires
long
YES
--
Expiration milliseconds, usually set to the current time plus 10 seconds
signature
string
YES
--
signature=sha256(apiSecret+method+path+expires)Note: The + needs to be removed to generate a signature
uid
string
1323056886107491328
User id
currency
string
USDT
currency
cash
double
0.01215991
cash
withdrawableCash
double
0
Withdrawable cash
frozenCash
double
0
Frozen cash
urPnl
double
0
Unrealized pnl
cashAvailable
double
0
Available cash
op
string
YES
--
subscribe/unsubscribe
channel
string
YES
positionUpdate
Event name
apiKey
string
YES
--
Apply at the individual center, apikey/apiSecret
expires
long
YES
--
Expiration milliseconds, usually set to the current time plus 10 seconds
signature
string
YES
--
signature=sha256(apiSecret+method+path+expires)Note: The + needs to be removed to generate a signature
uid
string
1323056886107491328
The User ID
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
symbol
string
BTCUSDT
The contract symbol
side
string
--
Direction of the position. Direction type: Long, Short
qty
double
11.0
Position quantity
price
double
4754.24
Price of position
closableQty
double
11.0
Closable quantity
pnlRate
double
-0.001
Pnl rate
value
double
11.0
Position value by currency
positionLeverage
double
11.0
Position leverage
liquidationPrice
double
11.0
Liquidation price
pnl
double
1.1
Realized pnl
urPnL
double
1.1
Unrealized pnl
deposit
double
1.1
deposit
lastPrice
double
1.1
Last price
created
long
1570759718825
Timestamp when the position is created
trailingStopPrice
double
--
Trailing stop price
stopLossPrice
double
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
--
Stop win price for advanced order
stopWinType
string
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
individualPosition
boolean
false
Individual position
op
string
YES
--
subscribe/unsubscribe
channel
string
YES
orderUpdate
Event name
apiKey
string
YES
--
Apply at the individual center, apikey/apiSecret
expires
long
YES
--
Expiration milliseconds, usually set to the current time plus 10 seconds
signature
string
YES
--
signature=sha256(apiSecret+method+path+expires)Note: The + needs to be removed to generate a signature
id
string
O101-20230531-025722-174-1016
The order ID
uid
string
1323056886107491328
The User ID
symbol
string
BTCUSDT
The contract symbol
created
long
1570759718825
Timestamp when the order is created
modified
long
1551062936784
Timestamp when this order was updated last time
clientOrderId
string
213443
An unique order ID which is defined by user
side
string
--
Direction of the order. Direction type: Buy, Sell
type
string
--
The order type, includes: LIMIT, Market
tif
string
GTC
Type of advanced order, Available values : FILL_OR_KILL, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, QUEUE_OR_CANCEL
currency
string
USDT
Currency of account, eg: BTC, ETH, USDT
price
double
8200
The order price
qty
double
11.0
Order quantity
openPosition
boolean
true
Open position or Close position order, eg: true or false
ordStatus
boolean
true
Open position or Close position order, eg: true or false
cumQty
double
11.0
The number of orders that have been executed
avgPx
double
4754.24
Average price of filled orders
ordStatus
string
FILLED
The order status, includes: PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELED, REJECTED, PENDING_REPLACE, REPLACED, WAITING
iceberg
boolean
false
The order is iceberg
showQty
double
1.0
The order showQty
pnl
double
1.1
Pnl incurred for this order.
fee
double
1.1
Fees incurred for this order.
triggerPrice
double
--
Trigger price for conditional order
triggerType
string
--
Trigger type of price for conditional order, eg: LAST or INDEX, it will be LAST if not providedAvailable values : INDEX, LAST, MARK
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
stopLossPrice
double
--
Stop loss price for advanced order, conflict with trailingStop
stopWinPrice
double
--
Stop win price for advanced order
stopWinType
string
--
Stop win type of price for advanced order, eg: Limit or Market, it's required if stopWinPrice is set Available values : Limit, Market
trailingStop
double
--
Trailing stop value for advanced order, conflict with stopLossPrice
0
OK
20003
Need to login before attempt any action
20004
System is offline
20013
Transaction sent too fast
20014
Account id doesn't exist
20032
Request is refused
20035
Balance is not enough
20040
User setting doesn't exist
20041
Ip address is prohibited
20043
Parameter format is wrong
20045
Order too fast
20048
Order too many
20088
Login blocked
20089
Operation too fast
20093
Subuser doesn't exist
20094
Subaccount doesn't exist
20095
Subaccount has been frozen
20096
Min Qty count limit
20097
Subaccount cash not zero
20109
The account has expired, please contact the administrator
20111
Account has triggered risk control, please contact the administrator
20117
Invalid token value
20118
Invalid order price
20120
User State disallows this action
20121
Operate frequently, try again 60 seconds later
20122
Operate frequently, try again 24 hours later
20125
Fund in account is changing, please try again later
20135
No permission
20138
Cancel limit exceeded. Try again in 24 hours
20140
Too many completed orders
20141
Too many incompleted orders
20146
Manage amount more than 30
21010
Exceeds the open position line
21011
Exceeds the max leverage setting
21012
Can't trade real contract with virtual currency
21013
Can't trade virtual contract with real currency
23016
Transaction is still pending
23017
Order qty inquiry error
24001
Symbol not found
24002
Invalid market
24003
Invalid currency
24004
Order quantity should be an integer multiple of lot size
24005
Order price should be an integer multiple of tick
25001
Order field is empty
25002
Order field error
25004
Order id already exists
25005
Order id not found
25006
Order already completed
25007
Account state disallow this action
25008
Daily order exceeds limit
25009
Invalid order quantity
25010
Data conversion error
25011
Order quantity must be greater than 0
25012
Order price must be greater than 0
25013
Can't amend up order qty
25014
One of price & qty must be specified to amend
25015
Cant allocate account for order
25016
Invalid order type
25017
Invalid order side
25018
Exchange order id not found
25019
No price for credit calculation
25020
Quote is invalid
25021
Insufficient fund
25022
There is pending order for this instrument
25025
Not enough closable qty for position
25027
Invalid trigger price
25029
Position exists in the account, please close it first
25030
Nothing is changed
25031
Invalid leverage value
25032
Invalid Stop loss price
25033
Invalid Stop win price
25034
Can't add deposit for none-individual position
25035
Empty position
25036
No enough position deposit to extract
25037
Maintenance margin is not enough
25038
Initial margin is not enough
25039
Risk limit is not correct
25040
Risk limit is exceeded
25041
Can't amend risk order
25042
Can't cancel risk order
25043
Price of buy order can't be less than stop loss
25044
Price of buy order can't be greater than stop win
25045
Price of sell order can't be greater than stop loss
25046
Price of sell order can't be less than stop win
25048
Account cash is not enough
25049
Risk limit is not enough
25051
Order price is out range of index price limitation
25052
Closing position, please wait
25053
Please close position first
25062
Net position would exceed the limit
25063
Invalid trigger type
25064
Invalid shown quantity
25065
Hidden order can't be passive
25066
Can't set both trailing stop & stop loss
25067
Please change only one parameter each time
25068
Can only set trigger price for conditional order
25069
Invalid trailing stop value
25070
Invalid stop win type
25071
Risk setting is not allowed for close position order
25072
Operating reversal order, please wait
25073
Operating close position, please wait
25074
Operating close position and cancel order, please wait