The detailed document https://docs.kucoin.com/futures/.
- Install library into your Maven's local repository by running
mvn install
- Add the following Maven dependency to your project's pom.xml:
<dependency>
<groupId>com.kucoin.futures</groupId>
<artifactId>kucoin-futures-java-sdk</artifactId>
<version>1.2.8</version>
</dependency>
KucoinFuturesClientBuilder builder = new KucoinFuturesClientBuilder().withBaseUrl("https://api-sandbox-futures.kucoin.com").withApiKey("YOUR_API_KEY", "YOUR_SECRET", "YOUR_PASS_PHRASE");
KucoinFuturesRestClient kucoinFuturesRestClient = builder.buildRestClient();
KucoinFuturesPrivateWSClient kucoinFuturesPrivateWSClient = builder.buildPrivateWSClient();
KucoinFuturesPublicWSClient kucoinFuturesPublicWSClient = builder.buildPublicWSClient();
You can use withBaseUrl
method to change evironment.
Environment | BaseUri |
---|---|
Production DEFAULT |
https://api-futures.kucoin.com |
If you only need to use the public web socket client or REST client public method, you can igonre withApiKey method. To customize your own API implementation, you may use the with*API method we provided for you. |
You need to sign the request to use the private user API.
kucoinFuturesRestClient.accountAPI().accountOverview();
kucoinFuturesRestClient.accountAPI().transactionHistory(type, pageRequest);
kucoinFuturesRestClient.depositAPI().getDepositAddress(currency);
kucoinFuturesRestClient.depositAPI().getDepositAddressList(status, pageRequest);
kucoinFuturesRestClient.withdrawalAPI().withdrawalAPI().getWithdrawList(status, pageRequest);
kucoinFuturesRestClient.withdrawalAPI().getWithdrawQuotas(currency);
WithdrawApplyRequest withdrawApplyRequest = WithdrawApplyRequest.builder().address(address)
.amount(amount).currency(currency).build();
kucoinFuturesRestClient.withdrawalAPI().withdrawFunds(withdrawApplyRequest);
kucoinFuturesRestClient.withdrawalAPI().cancelWithdraw(withdrawalId);
kucoinFuturesRestClient.transferAPI().getTransferOutRecords(status, pageRequest);
kucoinFuturesRestClient.transferAPI().toKucoinMainAccount(bizNo, amount);
kucoinFuturesRestClient.transferAPI().cancelTransferOutRequest(applyId)
You need to sign the request to use the private trade API.
OrderCreateApiRequest createRequest = OrderCreateApiRequest.builder()
.price(BigDecimal.valueOf(1000)).size(BigDecimal.ONE).side("buy").leverage("5")
.symbol(SYMBOL).type("limit").clientOid(UUID.randomUUID().toString()).build();
kucoinFuturesRestClient.orderAPI().getOrderDetail(orderId);
kucoinFuturesRestClient.orderAPI().cancelOrder(orderId);
kucoinFuturesRestClient.orderAPI().cancelAllOrders(symbol);
kucoinFuturesRestClient.orderAPI().getUntriggeredStopOrderList(symbol, sid, type, pageRequest);
kucoinFuturesRestClient.orderAPI().cancelAllStopOrders(symbol);
kucoinFuturesRestClient.orderAPI().getOrderList(symbol, side, type, status, pageRequest);
kucoinFuturesRestClient.orderAPI().getRecentDoneOrders();
kucoinFuturesRestClient.fillAPI().getFills(symbol, orderId, side, type, pageRequest);
kucoinFuturesRestClient.fillAPI().recentFills();
kucoinFuturesRestClient.fillAPI().calActiveOrderValue(symbol);
kucoinFuturesRestClient.positionAPI().getPosition(symbol);
kucoinFuturesRestClient.positionAPI().getPositions();
kucoinFuturesRestClient.positionAPI().setAutoDepositMargin(symbol, status);
kucoinFuturesRestClient.positionAPI().addMarginManually(symbol, margin, bizNo);
kucoinFuturesRestClient.fundingFeeAPI().getFundingHistory(symbol, reverse, forward, hasMoreRequest);
Market data is public and can be used without a signed request.
kucoinFuturesRestClient.symbolAPI().getContract(symbol);
kucoinFuturesRestClient.symbolAPI().getOpenContractList();
kucoinFuturesRestClient.symbolAPI().tickerAPI().getTicker(symbol);
kucoinFuturesRestClient.orderBookAPI().getFullLevel2OrderBook(symbol);
kucoinFuturesRestClient.orderBookAPI().getLevel2PullingMessages(symbol, sequenceStart, sequenceEnd);
kucoinFuturesRestClient.orderBookAPI().getFullLevel3OrderBook(symbol);
kucoinFuturesRestClient.orderBookAPI().getLevel3PullingMessages(symbol, sequenceStart, sequenceEnd);
kucoinFuturesRestClient.historyAPI().getTransactionHistories(symbol)
kucoinFuturesRestClient.indexAPI().getInterestRateList(symbol, reverse, forward, hasMoreRequest);
kucoinFuturesRestClient.timeAPI().getServerTimeStamp();
Use KucoinFuturesClientBuilder
to build an instance of the websocket client. Private channel client need to pass the API Key + Secret + Pass Phreas.
The Websocket client uses ChooseServerStrategy
to choose server for connection. If you don't plan to use builder.withChooseServerStrategy
to set your own strategy, you may use the strategy we provided by random.
wsClient.ping(requestId)
wsClient.unsubscribe(channelEnum, symbols);
wsClient.close();
kucoinFuturesPublicWSClient.onTicker(response -> {
System.out.println(response);
}, symbols);
kucoinFuturesPublicWSClient.onLevel2Data(response -> {
System.out.println(response);
}, symbols);
kucoinFuturesPublicWSClient.onExecutionData(response -> {
System.out.println(response);
}, symbols);
kucoinFuturesPublicWSClient.onLevel3Data(response -> {
System.out.println(response);
}, symbols);
kucoinFuturesPublicWSClient.onContractMarketData(response -> {
System.out.println(response);
}, symbols);
kucoinFuturesPublicWSClient.onTransactionStatistic(response -> {
System.out.println(response);
}, symbols);
kucoinPrivateWSClient.onStopOrderActivate(response -> {
System.out.println(response);
});
kucoinPrivateWSClient.onAccountBalance(response -> {
System.out.println(response);
});
kucoinPrivateWSClient.onPositionChange(response -> {
System.out.println(response);
}, symbols);
To contribute code or modify the library, you may enter the following command to run the test suite:
mvn clean test