Kucoin allows to trade with Futures using his REST API.
First you must create an API Key in your Kucoin account and add privileges to trading with Futures.
Once this is done, you can start futures 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.
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.
Param | type | Description |
---|---|---|
clientOid | String | Unique order id created by users to identify their orders, e.g. UUID, Only allows numbers, characters, underline(_), and separator(-) |
side | String | buy or sell |
symbol | String | a valid contract code. e.g. XBTUSDM |
type | String | [optional] Either limit or market |
leverage | String | Leverage of the order |
remark | String | [optional] remark for the order, length cannot exceed 100 utf8 characters |
stop | String | [optional] Either down or up. Requires stopPrice and stopPriceType to be defined |
stopPriceType | String | [optional] Either TP, IP or MP, Need to be defined if stop is specified. |
stopPrice | String | [optional] Need to be defined if stop is specified. |
reduceOnly | boolean | [optional] A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true. |
closeOrder | boolean | [optional] A mark to close the position. Set to false by default. It will close all the positions when closeOrder is true. |
forceHold | boolean | [optional] A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. |
Param | type | Description |
---|---|---|
price | String | Limit price |
size | Integer | Order size. Must be a positive number |
timeInForce | String | [optional] GTC, IOC(default is GTC), read Time In Force |
postOnly | boolean | [optional] Post only flag, invalid when timeInForce is IOC. When postOnly chose, not allowed choose hidden or iceberg. |
hidden | boolean | [optional] Orders not displaying in order book. When hidden chose, not allowed choose postOnly. |
iceberg | boolean | [optional] Only visible portion of the order is displayed in the order book. When iceberg chose, not allowed choose postOnly. |
visibleSize | Integer | [optional] The maximum visible size of an iceberg order |
Param | type | Description |
---|---|---|
size | Integer | [optional] amount of contract to buy or sell |
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 XBTUSDM
oKucoin := TsgcWSAPI_Kucoin_Futures.Create(nil);
oKucoin.Kucoin.ApiKey := '<api key>';
oKucoin.Kucoin.ApiSecret := '<api secret>';
oKucoin.Kucoin.Passphrase := '<passphrase>';
ShowMessage(oKucoin.REST_API.PlaceMarketOrder(kosBuy, 'XBTUSDM', 1));
Place Limit Order 1 XBTUSDM at 40000
oKucoin := TsgcWSAPI_Kucoin_Futures.Create(nil);
oKucoin.Kucoin.ApiKey := '<api key>';
oKucoin.Kucoin.ApiSecret := '<api secret>';
oKucoin.Kucoin.Passphrase := '<passphrase>';
ShowMessage(oKucoin.REST_API.PlaceLimitOrder(kosBuy, 'XBTUSDM', 1, 40000));