Kucoin | Trade Spot

Kucoin allows to trade with spot using his REST API.

 

Configuration

First you must create an API Key in your Kucoin account and add privileges to trading with Spot.

Once this is done, you can start spot trading.

First, set your ApiKey, ApiSecret and Passphrase in the Kucoin Client Component, this will be used to sign the requests sent to Kucoin server.

 

Place an Order

To place a new order, just call to method REST_API.PlaceOrder of Kucoin Client Component.

 

Depending of the type of the order (market, limit...) the API requires more or less fields.

 

Parameters

Param type Description
clientOid String Unique order id created by users to identify their orders, e.g. UUID.
side String buy or sell
symbol String a valid trading symbol code. e.g. ETH-BTC
type String [Optional] limit or market (default is limit)
remark String [Optional] remark for the order, length cannot exceed 100 utf8 characters
stp String [Optional] self trade prevention , CN, CO, CB or DC
tradeType String [Optional] The type of trading : TRADE(Spot Trade), MARGIN_TRADE (Margin Trade). Default is TRADE. Note: To improve the system performance and to accelerate order placing and processing, KuCoin has added a new interface for order placing of margin. For traders still using the current interface, please move to the new one as soon as possible. The current one will no longer accept margin orders by May 1st, 2021 (UTC). At the time, KuCoin will notify users via the announcement, please pay attention to it.

LIMIT ORDER PARAMETERS

Param type Description
price String price per base currency
size String amount of base currency to buy or sell
timeInForce String [Optional] GTC, GTT, IOC, or FOK (default is GTC), read Time In Force.
cancelAfter long [Optional] cancel after n seconds, requires timeInForce to be GTT
postOnly boolean [Optional] Post only flag, invalid when timeInForce is IOC or FOK
hidden boolean [Optional] Order will not be displayed in the order book
iceberg boolean [Optional] Only aportion of the order is displayed in the order book
visibleSize String [Optional] The maximum visible size of an iceberg order

MARKET ORDER PARAMETERS

Param type Description
size String [Optional] Desired amount in base currency
funds String [Optional] The desired amount of quote currency to use

 

When you send an order, there are 2 possibilities:

 

1. Successful: the function PlaceOrder returns the message sent by Kucoin server.

2. Error: the exception is returned in the event OnKucoinHTTPException.

 

 

Place Market Order 1 BTC-USDT


oKucoin := TsgcWSAPI_Kucoin.Create(nil);
oKucoin.Kucoin.ApiKey := '<api key>';
oKucoin.Kucoin.ApiSecret := '<api secret>';
oKucoin.Kucoin.Passphrase := '<passphrase>';
ShowMessage(oKucoin.REST_API.PlaceMarketOrder(kosBuy, 'BTC-USDT', 1));

 

Place Limit Order 1 BTC-USDT at 40000


oKucoin := TsgcWSAPI_Kucoin.Create(nil);
oKucoin.Kucoin.ApiKey := '<api key>';
oKucoin.Kucoin.ApiSecret := '<api secret>';
oKucoin.Kucoin.Passphrase := '<passphrase>';
ShowMessage(oKucoin.REST_API.PlaceLimitOrder(kosBuy, 'BTC-USDT', 1, 40000));