Add Order
POST
/api/v1/hf/orders:::info[Description]
Place order to the Spot trading system, you can place two major types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your funds will be put on hold for the duration of the order. The amount of funds on hold depends on the order type and parameters specified.
:::
:::tip[Tips]
Please note that once your order enters the order book, the system will freeze the handling fees for the order ahead of time.
Before placing orders, please be sure to fully understand the meaning of the parameters for each trading pair.
:::
:::tip[Tips]
The maximum number of active orders per account is 2000, with a maximum of 200 active orders per trading pair.
:::
Public order placement request parameters
Param | Type | Mandatory | Description |
---|---|---|---|
clientOid | String | No | Client Order Id,unique identifier created by the user, the use of UUID is recommended |
symbol | String | Yes | symbol |
type | String | Yes | Order type limit and market |
side | String | Yes | buy or sell |
stp | String | No | self trade prevention is divided into four strategies: CN , CO , CB , and DC |
tags | String | No | Order tag, length cannot exceed 20 characters (ASCII) |
remark | String | No | Order placement remarks, length cannot exceed 20 characters (ASCII) |
Additional Request Parameters Required by limit
Orders
Param | Type | Mandatory | Description |
---|---|---|---|
price | String | Yes | Specify price for currency |
size | String | Yes | Specify quantity for currency |
timeInForce | String | No | Order timing strategy GTC , GTT , IOC , FOK (The default is GTC ) |
cancelAfter | long | No | Cancel after n seconds,the order timing strategy is GTT |
postOnly | boolean | No | passive order labels, this is disabled when the order timing strategy is IOC or FOK |
hidden | boolean | No | Hidden or not (not shown in order book) |
iceberg | boolean | No | Whether or not only visible portions of orders are shown in iceberg orders |
visibleSize | String | No | Maximum visible quantity in iceberg orders |
Additional request parameters required by market
orders
Param | Type | Mandatory | Description |
---|---|---|---|
size | String | No | (Select one out of two: size or funds ) |
funds | String | No | (Select one out of two: size or funds ) |
Hold
For limit price purchase orders, we will hold the amount of funds (price * size) required for your purchase order. Similarly, for limit price sell orders, we will also hold you sell order assets. When the transaction is executed, the service fees will be calculated. If you cancel a portion of a filled or unfilled order, then the remaining funds or amounts will be released and returned to your account. For market price buy/sell orders that require specific funds, we will hold the required funds in from your account. If only the size is specified, we may freeze (usually for a very short amount of time) all of the funds in your account prior to the order being filled or cancelled.
Order Lifecycle
When an order placement request is successful (the matching engine receives the order) or denied (due to there being insufficient funds or illegal parameter values, etc.), the system will respond to the HTTP request. When an order is successfully placed, the order ID is returned. The order will be matched, which could result in it being fully or partially filled. When an order is fully or partially filled, the remaining portions of the order will be in an active state awaiting to be matched (this does not include IOC orders). Orders that are fully or partially filled(already cancelled) will be put into the “done” state.
Users that have subscribed to the Market Data Channel can use the order ID (orderId) and client ID (clientOid) to identify messages.
Price Protection Mechanisms
Price protection mechanisms ae enabled for order placements. Rules are detailed below:
If the spot trading market order/limit order placed by the user can be directly matched with an order in the current order book, the system will judge whether deviation between the price corresponding to the transaction depth and the spread exceeds the threshold value (the threshold value can be obtained using the symbol API endpoint);
If it is exceeded, for limit orders, the order will be directly cancelled;
If it is a market order, then the system will partially execute the order. The execution limit will be the order size within the price range corresponding to the threshold value. The remaining orders will not be filled.
For example: if the threshold value is 10%, when a user places a market price purchase order in the KCS/USDT trading market for 10,000 USDT (the selling price is currently 1.20000), the system will determine that after the order is completely filled, the final price will be 1.40000. (1.40000-1.20000)/1.20000=16.7%>10%. The threshold value is 1.32000. The user’s market price purchase order will be filled only to a maximum of 1.32000. The remaining order portions will not be matched with orders in the order book. Note: this feature may not be able to determine depth with complete accuracy. If your order is not completely filled, it may be because the portion exceeding the threshold value was not filled.
Request
specify if the order is an 'limit' order or 'market' order.
The type of order you specify when you place your order determines whether or not you need to request other parameters and also affects the execution of the matching engine.
When placing a limit order, you must specify a price and size. The system will try to match the order according to market price or a price better than market price. If the order cannot be immediately matched, it will stay in the order book until it is matched or the user cancels.
Unlike limit orders, the price for market orders fluctuates with market prices. When placing a market order, you do not need to specify a price, you only need to specify a quantity. Market orders are filled immediately and will not enter the order book. All market orders are takers and a taker fee will be charged.
symbol
specify if the order is to 'buy' or 'sell'
Client Order Id,The ClientOid field is a unique ID created by the user(we recommend using a UUID), and can only contain numbers, letters, underscores (_), and hyphens (-). This field is returned when order information is obtained. You can use clientOid to tag your orders. ClientOid is different from the order ID created by the service provider. Please do not initiate requests using the same clientOid. The maximum length for the ClientOid is 40 characters.
Please remember the orderId created by the service provider, it used to check for updates in order status.
Specify price for order
When placing a limit order, the price must be based on priceIncrement for the trading pair. The price increment (priceIncrement) is the price precision for the trading pair. For example, for the BTC-USDT trading pair, the priceIncrement is 0.00001000. So the price for your orders cannot be less than 0.00001000 and must be a multiple of priceIncrement. Otherwise, the order will return an invalid priceIncrement error.
Self Trade Prevention is divided into four strategies: CN, CO, CB , and DC
Order tag, length cannot exceed 20 characters (ASCII)
Order placement remarks, length cannot exceed 20 characters (ASCII)
Time in force is a special strategy used during trading
Cancel after n seconds,the order timing strategy is GTT
passive order labels, this is disabled when the order timing strategy is IOC or FOK
Whether or not only visible portions of orders are shown in Iceberg orders
Maximum visible quantity in iceberg orders
Specify quantity for order
When type is limit, size refers to the amount of trading targets (the asset name written in front) for the trading pair. Teh Size must be based on the baseIncrement of the trading pair. The baseIncrement represents the precision for the trading pair. The size of an order must be a positive-integer multiple of baseIncrement and must be between baseMinSize and baseMaxSize.
When type is market, select one out of two: size or funds
When type is market, select one out of two: size or funds
//limit order
{
"type": "limit",
"symbol": "BTC-USDT",
"side": "buy",
"price": "50000",
"size": "0.00001",
"clientOid": "5c52e11203aa677f33e493fb",
"remark": "order remarks"
}
//market order 1
// {
// "type": "market",
// "symbol": "BTC-USDT",
// "side": "buy",
// "size": "0.00001",
// "clientOid": "5c52e11203aa677f33e493fc",
// "remark": "order remarks"
// }
//market order 2
// {
// "type": "market",
// "symbol": "BTC-USDT",
// "side": "buy",
// "funds": "1",
// "clientOid": "5c52e11203aa677f33e493fc",
// "remark": "order remarks"
// }
Request samples
Responses
The unique order id generated by the trading system,which can be used later for further actions such as canceling the order.
The user self-defined order id.
{
"code": "200000",
"data": {
"orderId": "670fd33bf9406e0007ab3945",
"clientOid": "5c52e11203aa677f33e493fb"
}
}