Giter VIP home page Giter VIP logo

kucoin-futures-java-sdk's Introduction

JAVA SDK for KucoinFutures API

The detailed document https://docs.kucoin.com/futures/.

Latest Version

Build Status

Installation

  1. Install library into your Maven's local repository by running mvn install
  2. 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.6</version>
</dependency>

Usage

Build Client

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.

Example

REST API

User

You need to sign the request to use the private user API.

Accounts
kucoinFuturesRestClient.accountAPI().accountOverview();
kucoinFuturesRestClient.accountAPI().transactionHistory(type, pageRequest);          
Deposits
kucoinFuturesRestClient.depositAPI().getDepositAddress(currency);
kucoinFuturesRestClient.depositAPI().getDepositAddressList(status, pageRequest);
Withdrawals
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);
Transfer
kucoinFuturesRestClient.transferAPI().getTransferOutRecords(status, pageRequest);
kucoinFuturesRestClient.transferAPI().toKucoinMainAccount(bizNo, amount);
kucoinFuturesRestClient.transferAPI().cancelTransferOutRequest(applyId)

Trade

You need to sign the request to use the private trade API.

Orders
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();
Fills
kucoinFuturesRestClient.fillAPI().getFills(symbol, orderId, side, type, pageRequest);
kucoinFuturesRestClient.fillAPI().recentFills();
kucoinFuturesRestClient.fillAPI().calActiveOrderValue(symbol);
Positions
kucoinFuturesRestClient.positionAPI().getPosition(symbol);
kucoinFuturesRestClient.positionAPI().getPositions();
kucoinFuturesRestClient.positionAPI().setAutoDepositMargin(symbol, status);
kucoinFuturesRestClient.positionAPI().addMarginManually(symbol, margin, bizNo);
Funding Fees
kucoinFuturesRestClient.fundingFeeAPI().getFundingHistory(symbol, reverse, forward, hasMoreRequest);

Market Date

Market data is public and can be used without a signed request.

Symbols
kucoinFuturesRestClient.symbolAPI().getContract(symbol);
kucoinFuturesRestClient.symbolAPI().getOpenContractList();
Ticker
kucoinFuturesRestClient.symbolAPI().tickerAPI().getTicker(symbol);
Order Book
kucoinFuturesRestClient.orderBookAPI().getFullLevel2OrderBook(symbol);
kucoinFuturesRestClient.orderBookAPI().getLevel2PullingMessages(symbol, sequenceStart, sequenceEnd);
kucoinFuturesRestClient.orderBookAPI().getFullLevel3OrderBook(symbol);
kucoinFuturesRestClient.orderBookAPI().getLevel3PullingMessages(symbol, sequenceStart, sequenceEnd);
Histories
kucoinFuturesRestClient.historyAPI().getTransactionHistories(symbol)
Index
kucoinFuturesRestClient.indexAPI().getInterestRateList(symbol, reverse, forward, hasMoreRequest);
Time
kucoinFuturesRestClient.timeAPI().getServerTimeStamp();

Websocket Feed

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.

Ping

wsClient.ping(requestId)

Unsubscribe

wsClient.unsubscribe(channelEnum, symbols);

Close Client

wsClient.close();

Public Channels

Listen for changes to the order boock for ETH-BTC and KCS-BTC
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);

Private Channels

Listen for stop order activate message
kucoinPrivateWSClient.onStopOrderActivate(response -> {
            System.out.println(response);
        });
Listen for account balance changes
kucoinPrivateWSClient.onAccountBalance(response -> {
            System.out.println(response);
        });
Listen for position change message
kucoinPrivateWSClient.onPositionChange(response -> {
            System.out.println(response);
        }, symbols);

Testing

To contribute code or modify the library, you may enter the following command to run the test suite:

mvn clean test

License

MIT

kucoin-futures-java-sdk's People

Contributors

1bazinga25 avatar blazetan avatar casoc avatar jasonyao2107 avatar kuka36 avatar whynotrecord avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.