reactive-crypto

💲📈A Kotlin/Java library for cryptocurrency trading. Supporting REST Api and WebSockets non-blocking client base on Reactor Netty

namjug-kim/reactive-crypto
starsStars 49
forksForks 12
watchersWatchers 49
current-versionCurrent version 0.2.3.RELEASE
total-releasesTotal releases 13
open_issues_countOpen issues 21
dateFirst release 2019-05-04
dateLatest release 2019-07-22
updateLast update 2020-12-21



Reactive Crypto

A Kotlin library for cryptocurrency trading.

Supported Exchanges

Websocket

Support public market feature (tickData, orderBook)

logo name ExchangeVendor ver doc
Binance BINANCE * ws
Upbit UPBIT v1.0.3 ws
Huobi Global HUOBI_GLOBAL * ws
Huobi Korea HUOBI_KOREA * ws
Huobi Japan HUOBI_JAPAN * ws
Okex OKEX v3 ws
Okex Korea OKEX_KOREA v3 ws
Bithumb BITHUMB deprecated ⚠️
Hubi HUBI * ws
Bitmex BITMEX * ws
Kraken KRAKEN 0.1.1 ws
Bitmax BITMAX v1.2 ws
Idax IDAX * ws
Coineal COINEAL ⚠️ ⚠️
Poloniex POLONIEX * ws
Bitstamp BITSTAMP v2 ws
Korbot EX KOTBOTEX v3 ws
Coinall COINALL v3 ws
Bhex BHEX v1 ws
Bit-Z BITZ * ws

⚠️ : Uses endpoints that are used by the official web. This is not an official api and should be used with care.

Api

Exchange ver doc

Install

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Step 1. Add jitpack repository

<dependency>
    <groupId>com.github.namjug-kim.reactive-crypto</groupId>
    <artifactId>reactive-crypto-{exchange-name}</artifactId>
    <version>LATEST</version>
</dependency>

Step 2. Add the dependency

Gradle

repositories {
	...
	maven { url 'https://jitpack.io' }
}

Step 1. Add jitpack repository

dependencies {
    implementation 'com.github.namjug-kim.reactive-crypto:reactive-crypto-{exchange-name}:LATEST'
}

Step 2. Add the dependency

Usage

Kotlin

fun websocketTickDataExample() {
    // create websocketClient for each crypto currency exchange
    val websocketClient = ExchangeClientFactory.websocket(ExchangeVendor.BINANCE)
    
    websocketClient.createTradeWebsocket(listOf(CurrencyPair(BTC, USDT)))
                   .doOnNext { log.info { "new tick data $it" } }
                   .subscribe()
}

fun httpLimitOrderExample() {
    val orderPlaceResult = ExchangeClientFactory.http(ExchangeVendor.BINANCE)
                .privateApi("accessKey", "secretKey")
                .order()
                .limitOrder(
                    CurrencyPair(Currency.BTC, Currency.KRW),
                    TradeSideType.BUY,
                    BigDecimal.valueOf(10000000.0),
                    BigDecimal.valueOf(10.0)
                )
                .block()

    log.info { orderPlaceResult }
}

Java

class SampleClass {
    public void websocketTickDataExample() {
        // create websocketClient for each crypto currency exchange
        ExchangeWebsocketClient exchangeWebsocketClient = ExchangeClientFactory.websocket(ExchangeVendor.BINANCE);
         
        List<CurrencyPair> targetPairs = Collections.singletonList(CurrencyPair.parse("BTC", "USDT"));
        exchangeWebsocketClient.createTradeWebsocket(targetPairs)
                               .doOnNext(tickData -> log.info("new tick data {}", tickData))
                               .subscribe();
    }

    public void httpLimitOrderExample() {
        OrderPlaceResult orderPlaceResult = ExchangeClientFactory.http(ExchangeVendor.BINANCE)
                        .privateApi("accessKey", "secretKey")
                        .order()
                        .limitOrder(
                            CurrencyPair(Currency.BTC, Currency.KRW),
                            TradeSideType.BUY,
                            BigDecimal.valueOf(10000000.0),
                            BigDecimal.valueOf(10.0)
                        )
                        .block();

        log.info("{}", orderPlaceResult);
    }

}