KUCOIN API
HomeChange LogAPI DOC V1
Language
  • 繁體中文(即將上綫)
  • Русский (скоро)
HomeChange LogAPI DOC V1
More
SDK
Telegram
Kucoin
  1. REST
  2. Margin Trading
  3. Orders
  • Introduction
  • Authentication
  • Enums Definitions
  • Terms Definitions
  • SDK
  • Rate Limit
  • Change Log
  • User Service
    • Market Making Incentive Scheme
    • VIP Fast Track
    • Broker Program
  • REST
    • Account Info
      • Account & Funding
        • Get Account Summary Info
        • Get Apikey Info
        • Get Account Type - Spot
        • Get Account List - Spot
        • Get Account Detail - Spot
        • Get Account - Cross Margin
        • Get Account - Isolated Margin
        • Get Account - Futures
        • Get Account Ledgers - Spot/Margin
        • Get Account Ledgers - Trade_hf
        • Get Account Ledgers - Margin_hf
        • Get Account Ledgers - Futures
      • Sub Account
        • Add sub-account
        • Add sub-account Margin Permission
        • Add sub-account Futures Permission
        • Get sub-account List - Summary Info
        • Get sub-account Detail - Balance
        • Get sub-account List - Spot Balance (V2)
        • Get sub-account List - Futures Balance (V2)
      • Sub Account API
        • Add sub-account API
        • Modify sub-account API
        • Get sub-account API List
        • Delete sub-account API
      • Deposit
        • Add Deposit Address (V3)
        • Get Deposit Address (V3)
        • Get Deposit History
      • Withdrawals
        • Get Withdrawal Quotas
        • Withdraw (V3)
        • Cancel Withdrawal
        • Get Withdrawal History
        • Get Withdrawal History By ID
      • Transfer
        • Get Transfer Quotas
        • Flex Transfer
      • Trade Fee
        • Get Basic Fee - Spot/Margin
        • Get Actual Fee - Spot/Margin
        • Get Actual Fee - Futures
    • Spot Trading
      • Market Data
        • Get Announcements
        • Get Currency
        • Get All Currencies
        • Get Symbol
        • Get All Symbols
        • Get Ticker
        • Get All Tickers
        • Get Trade History
        • Get Klines
        • Get Part OrderBook
        • Get Full OrderBook
        • Get Call Auction Part OrderBook
        • Get Call Auction Info
        • Get Fiat Price
        • Get 24hr Stats
        • Get Market List
        • Get Client IP Address
        • Get Server Time
        • Get Service Status
      • Orders
        • Add Order
        • Add Order Sync
        • Add Order Test
        • Batch Add Orders
        • Batch Add Orders Sync
        • Cancel Order By OrderId
        • Cancel Order By OrderId Sync
        • Cancel Order By ClientOid
        • Cancel Order By ClientOid Sync
        • Cancel Partial Order
        • Cancel All Orders By Symbol
        • Cancel All Orders
        • Modify Order
        • Get Order By OrderId
        • Get Order By ClientOid
        • Get Symbols With Open Order
        • Get Open Orders
        • Get Open Orders By Page
        • Get Closed Orders
        • Get Trade History
        • Get DCP
        • Set DCP
        • Add Stop Order
        • Cancel Stop Order By ClientOid
        • Cancel Stop Order By OrderId
        • Batch Cancel Stop Orders
        • Get Stop Orders List
        • Get Stop Order By OrderId
        • Get Stop Order By ClientOid
        • Add OCO Order
        • Cancel OCO Order By OrderId
        • Cancel OCO Order By ClientOid
        • Batch Cancel OCO Order
        • Get OCO Order By OrderId
        • Get OCO Order By ClientOid
        • Get OCO Order Detail By OrderId
        • Get OCO Order List
    • Margin Trading
      • Market Data
        • Get Symbols - Cross Margin
        • Get ETF Info
        • Get Mark Price Detail
        • Get Margin Config
        • Get Mark Price List
        • Get Symbols - Isolated Margin
      • Orders
        • Add Order
          POST
        • Add Order Test
          POST
        • Cancel Order By OrderId
          DELETE
        • Cancel Order By ClientOid
          DELETE
        • Cancel All Orders By Symbol
          DELETE
        • Get Symbols With Open Order
          GET
        • Get Open Orders
          GET
        • Get Closed Orders
          GET
        • Get Trade History
          GET
        • Get Order By OrderId
          GET
        • Get Order By ClientOid
          GET
      • Debit
        • Borrow
        • Get Borrow History
        • Repay
        • Get Repay History
        • Get Interest History.
        • Modify Leverage
      • Credit
        • Get Loan Market
        • Get Loan Market Interest Rate
        • Purchase
        • Modify Purchase
        • Get Purchase Orders
        • Redeem
        • Get Redeem Orders
      • Risk Limit
        • Get Margin Risk Limit
    • Futures Trading
      • Market Data
        • Get Symbol
        • Get All Symbols
        • Get Ticker
        • Get All Tickers
        • Get Full OrderBook
        • Get Part OrderBook
        • Get Trade History
        • Get Klines
        • Get Mark Price
        • Get Spot Index Price
        • Get Interest Rate Index
        • Get Premium Index
        • Get 24hr stats
        • Get Server Time
        • Get Service Status
      • Orders
        • Add Order
        • Add Order Test
        • Batch Add Orders
        • Add Take Profit And Stop Loss Order
        • Cancel Order By OrderId
        • Cancel Order By ClientOid
        • Batch Cancel Orders
        • Cancel All Orders
        • Cancel All Stop orders
        • Get Order By OrderId
        • Get Order By ClientOid
        • Get Order List
        • Get Recent Closed Orders
        • Get Stop Order List
        • Get Open Order Value
        • Get Recent Trade History
        • Get Trade History
      • Positions
        • Get Margin Mode
        • Switch Margin Mode
        • Batch Switch Margin Mode
        • Get Max Open Size
        • Get Position Details
        • Get Position List
        • Get Positions History
        • Get Max Withdraw Margin
        • Get Cross Margin Leverage
        • Modify Cross Margin Leverage
        • Add Isolated Margin
        • Remove Isolated Margin
        • Get Cross Margin Risk Limit
        • Get Isolated Margin Risk Limit
        • Modify Isolated Margin Risk Limit
      • Funding Fees
        • Get Current Funding Rate.
        • Get Public Funding History
        • Get Private Funding History
    • Copy Trading
      • Introduction
      • Add Order
      • Add Order Test
      • Add Take Profit And Stop Loss Order
      • Cancel Order By OrderId
      • Cancel Order By ClientOid
      • Get Max Open Size
      • Get Max Withdraw Margin
      • Add Isolated Margin
      • Remove Isolated Margin
      • Modify Isolated Margin Risk Limit
      • Modify Isolated Margin Auto-Deposit Status
    • Earn
      • Purchase
      • Get Redeem Preview
      • Redeem
      • Get Savings Products
      • Get Promotion Products
      • Get Staking Products
      • Get KCS Staking Products
      • Get ETH Staking Products
      • Get Account Holding
    • VIP Lending
      • Introduction
      • Get Discount Rate Configs
      • Get Loan Info
      • Get Accounts
    • Affiliate
      • Introduction
      • Get Account
    • Broker
      • Introduction
      • Broker Application
      • Instructions
      • API Broker
        • Introduction
        • Get Broker Rebate
      • Exchange Broker
        • Introduction
        • Submit KYC
        • Get KYC Status
        • Get KYC Status List
        • Get Broker Info
        • Add sub-account
        • Get sub-account
        • Add sub-account API
        • Get sub-account API
        • Modify sub-account API
        • Delete sub-account API
        • Transfer
        • Get Transfer History
        • Get Deposit List
        • Get Deposit Detail
        • Get Withdraw Detail
        • Get Broker Rebate
  • Websocket API
    • Base Info
      • Introduction
      • Get Public Token - Spot/Margin
      • Get Private Token - Spot/Margin
      • Get Public Token - Futures
      • Get Private Token - Futures
    • Spot Trading
      • Public Channels
        • Ticker
        • All Tickers
        • Orderbook - Level1
        • Orderbook - Level5
        • Orderbook - Level50
        • Orderbook - Increment
        • Call Auction Orderbook - Level50
        • Call Auction Data
        • Klines
        • Trade
        • Symbol Snapshot
        • Market Snapshot
      • Private Channels
        • Order V2
        • Order V1
        • Balance
        • Stop Order
    • Margin Trading
      • Public Channels
        • Index Price
        • Mark Price
      • Private Channels
        • Cross Margin Position
        • Isolated Margin Position
    • Futures Trading
      • Public Channels
        • Ticker V2
        • Ticker V1
        • Orderbook - Level5
        • Orderbook - Level50
        • Orderbook- Increment
        • Klines
        • Trade
        • Instrument
        • Funding Fee Settlement
        • Symbol Snapshot
      • Private Channels
        • Orders
        • Balance
        • Positions
        • Margin Mode
        • Cross Margin Leverage
        • Stop Orders
  • Error Code
    • HTTP
    • Spot
    • Margin
    • Futures
    • Earn
    • Broker
    • CopyTrading
  • Abandoned Endpoints
    • Introduction
    • Account & Funding
      • Get sub-account List - Summary Info (V1)
      • Get sub-account List - Spot Balance (V1)
      • Get Deposit Addresses (V2)
      • Get Deposit Addresses - V1
      • Sub-account Transfer
      • Get Deposit History - Old
      • Internal Transfer
      • Get Futures Account Transfer Out Ledger
      • Get Withdrawal History - Old
      • Futures Account Transfer Out
      • Futures Account Transfer In
      • Add Deposit Address - V1
      • Withdraw - V1
    • Spot Trading
      • Orders
        • Add Order - Old
        • Add Order Test - Old
        • Batch Add Orders - Old
        • Cancel Order By OrderId - Old
        • Cancel Order By ClientOid - Old
        • Batch Cancel Order - Old
        • Get Orders List - Old
        • Get Recent Orders List - Old
        • Get Order By OrderId - Old
        • Get Order By ClientOid - Old
        • Get Trade History - Old
        • Get Recent Trade History - Old
    • Margin Trading
      • Get Account Detail - Margin
      • Add Order - V1
      • Add Order Test - V1
      • Get Account List - Isolated Margin - V1
      • Get Account Detail - Isolated Margin - V1
    • Futures Trading
      • Modify Isolated Margin Auto-Deposit Status
      • Cancel All Orders - V1
  • Developing
    • Introduction
    • Websocket API
      • Add Order
      • Cancel Order
    • Get Account
    • Get Transfer Quotas
    • Flex Transfer
    • Get Account Ledger
  1. REST
  2. Margin Trading
  3. Orders

Add Order

POST
https://api.kucoin.com/api/v3/hf/margin/order
domain:Spot
api-channel:Private
api-permission:Margin
api-rate-limit-pool:Spot
sdk-service:Margin
sdk-sub-service:Order
sdk-method-name:addOrder
api-rate-limit-weight:5
Description
Place order in the Cross-margin or Isolated-margin trading system. You can place two major types of order: 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.
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.
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
ParamTypeMandatoryDescription
clientOidStringYesClient Order ID, unique identifier created by the user, the use of UUID is recommended
symbolStringYessymbol
sideStringYes‘buy’ or ‘sell’
typeStringNoOrder type ‘limit’ and ‘market’, default is limit
stpStringNoself trade prevention is divided into four strategies: ‘CN’, ‘CO’, ‘CB’, and ‘DC’
isIsolatedbooleanNotrue - isolated margin, false - cross margin. Default is false
autoBorrowbooleanNoWhen Margin Account has inefficient balance, our system autoborrows inefficient assets and opens positions according to the lowest market interest rate.
autoRepaybooleanNoAutoPay allows returning borrowed assets when you close a position. Our system automatically triggers the repayment and the maximum repayment amount equals to the filled-order amount.
Additional Request Parameters Required by ‘limit’ Orders
ParamTypeMandatoryDescription
priceStringYesSpecify price for currency
sizeStringYesSpecify quantity for currency
timeInForceStringNoOrder timing strategy ‘GTC’, ‘GTT’, ‘IOC’, ‘FOK’ (the default is ‘GTC’)
cancelAfterlongNoCancel after ‘n’ seconds, the order timing strategy is ‘GTT’
postOnlybooleanNopassive order labels, this is disabled when the order timing strategy is ‘IOC’ or ‘FOK’
hiddenbooleanNoHidden or not (not shown in order book)
icebergbooleanNoWhether or not only visible portions of orders are shown in iceberg orders
visibleSizeStringNoMaximum visible quantity in iceberg orders
Additional request parameters required by ‘market’ orders
ParamTypeMandatoryDescription
sizeStringNo(Select one out of two: ‘size’ or ‘funds’)
fundsStringNo(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 canceled.
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 canceled) 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 canceled;
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

Body Params application/json
clientOid
string 
required
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.
Example:
5c52e11203aa677f33e493fb
symbol
string 
required
symbol
Examples:
BTC-USDTETH-USDTKCS-USDT
side
enum<string> 
required
Specify if the order is to 'buy' or 'sell'.
Allowed values:
buysell
Example:
buy
type
enum<string> 
optional
Specify if the order is a '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.
Allowed values:
limitmarket
Default:
limit
price
string 
optional
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.
stp
enum<string> 
optional
Self Trade Prevention is divided into these strategies: CN, CO, CB , and DC
Allowed values:
DCCOCNCB
isIsolated
boolean 
optional
True - isolated margin; false - cross margin. Default is false
Default:
false
autoBorrow
boolean 
optional
When Margin Account has inefficient balance, our system autoborrows inefficient assets and opens positions according to the lowest market interest rate.
Default:
false
autoRepay
boolean 
optional
AutoPay allows the return of borrowed assets when you close a position. Our system automatically triggers the repayment and the maximum repayment amount equals to the filled-order amount.
Default:
false
timeInForce
enum<string> 
optional
Time in force is a special strategy used during trading
Allowed values:
GTCGTTIOCFOK
Default:
GTC
cancelAfter
integer <int64>
optional
Cancel after n seconds, the order timing strategy is GTT
postOnly
boolean 
optional
passive order labels, this is disabled when the order timing strategy is IOC or FOK
Default:
false
hidden
boolean 
optional
Hidden order or not (not shown in order book)
Default:
false
iceberg
boolean 
optional
Whether or not only visible portions of orders are shown in Iceberg orders
Default:
false
visibleSize
string 
optional
Maximum visible quantity in iceberg orders
size
string 
optional
Specify quantity for order.
When type is limited, size refers to the amount of trading targets (the asset name written in front) for the trading pair. The 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
funds
string 
optional
When type is market, select one out of two: size or funds
Example
//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

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
curl --location --request POST 'https://api.kucoin.com/api/v3/hf/margin/order' \
--header 'Content-Type: application/json' \
--data-raw '//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"
// }'

Responses

🟢200OK
application/json
Body
code
string 
required
data
object 
required
orderId
string 
required
The unique order ID generated by the trading system, which can be used later for further actions such as canceling the order.
clientOid
string 
required
The user self-defined order ID.
borrowSize
string 
required
Borrowed amount. The field is returned only after placing the order under the mode of Auto-Borrow.
loanApplyId
string 
required
Borrow order ID. The field is returned only after placing the order under the mode of Auto-Borrow.
Example
{
  "success": true,
  "code": "200000",
  "data": {
    "orderId": "671663e02188630007e21c9c",
    "clientOid": "5c52e11203aa677f33e1493fb",
    "borrowSize": "10.2",
    "loanApplyId": "600656d9a33ac90009de4f6f"
  }
}
Modified at 3 months ago
Previous
Get Symbols - Isolated Margin
Next
Add Order Test