Skip to main content

Place an Order

API Description

This interface allows users to place spot trading orders by specifying the order type, quantity, price, and an external transaction number.

Note: Historical Orders is only available via RESTful API.

Precautions

  1. For market orders, user can specify either "funds" or "amount".
  2. For limit order, user need to specify "amount"

Authentication

This is a private interface and requires authentication. For details on using the RESTful API, refer to Introduction > Authentication & Code Snippet > Spot > RESTful Private Interface.

Request Method

POST

Endpoint

/api/v1/private?command=doTrade

Frequency Limit

The frequency limit for this interface is 30 requests/2s per user ID. In addition to this per-interface limit, a global rate limit is also enforced.

For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here

Request Parameters

ParameterMandatoryTypeDescription
symbolTrueStringTrading instrument such as: BTC_USDT
typeTrueStringTrade direction:
0: Buy order,
1: Sell order.
amountFalseStringOrder size in base currency.
Note: Mandatory for limit order.
rateFalseStringOrder price specified by user (for Limit order only)
fundsFalseStringOrder size in quote currency.
Note: Valid only for market orders.
isMarketTrueStringOrder type:
true: market order,
false: limit order.
out_trade_noTrueStringA custom order ID assigned by the user. User need to make it unique to distinguish different orders
Note: Maximum length: 50 characters; only latin characters, numbers, hyphens (-), and underscores (_) are permitted.

Response Parameters

ParameterTypeDescription
orderNumberStringOrder id

Request Example

The following Python code shows how to place limit order for BTC-USDT.

Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Spot > Restful Private Interface.

api_url = "/api/v1/private?command=doTrade"
method = "post"
params = {
"symbol": "BTC_USDT",
"type": "0",
"amount": "0.0001",
"rate": "82000" ,
# "funds" : 100,
"isMarket" : "false",
"out_trade_no" : "3-04-11-06"
}
SpotRestfulPrivate(host, api_url, method, api_key, params, secret_key) # function SpotRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Spot > RESTful Private Interface)

Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Private Interface.

Response Example

The following is an example response returned by the above Python request:

{'code': '200',
'data': {'orderNumber': 4624603081039753080},
'msg': 'SUCCESS',
'success': True,
'failed': False}