Giter Club home page Giter Club logo

namjug-kim / reactive-crypto Goto Github PK

View Code? Open in Web Editor NEW
96.0 10.0 28.0 749 KB

๐Ÿ’ฒ๐Ÿ“ˆA Kotlin/Java library for cryptocurrency trading. Supporting REST Api and WebSockets non-blocking client base on Reactor Netty

License: Apache License 2.0

Kotlin 84.81% Java 15.19%
altcoin api bitcoin cryptocurrency binance bithumb upbit huobi okex kraken bitmex bitmax websocket arbitrage market-making trading-bot bitstamp poloniex cryptocurrency-trading bhex

reactive-crypto's Introduction



Reactive Crypto

Kotlin CircleCI codecov jitpack ktlint

A Kotlin library for cryptocurrency trading.

Supported Exchanges

Websocket

Support public market feature (tickData, orderBook)

logo name ExchangeVendor ver doc
binance Binance BINANCE * ws
upbit Upbit UPBIT v1.0.3 ws
huobi_global Huobi Global HUOBI_GLOBAL * ws
huobi korea Huobi Korea HUOBI_KOREA * ws
huobi_japan Huobi Japan HUOBI_JAPAN * ws
okex Okex OKEX v3 ws
okex_korea Okex Korea OKEX_KOREA v3 ws
unicornx UnicornX UNICORNX v3 ws
hubi Hubi HUBI * ws
bitmex Bitmex BITMEX * ws
kraken Kraken KRAKEN 0.1.1 ws
bitmax Bitmax BITMAX v1.2 ws
coineal Coineal COINEAL โš ๏ธ โš ๏ธ
poloniex Poloniex POLONIEX * ws
bitstamp Bitstamp BITSTAMP v2 ws
korbotex Korbot EX KOTBOTEX v3 ws
coinall Coinall COINALL v3 ws
bhex Bhex BHEX v1 ws
bitz Bit-Z BITZ * ws
idax Idax IDAX closed ws
bithumb Bithumb BITHUMB deprecated โš ๏ธ

โš ๏ธ : 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);
    }

}

๐Ÿ’ฌ Contributing

๐Ÿ“œ License

reactive-crypto's People

Contributors

dependabot-preview[bot] avatar namjug-kim avatar traeper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactive-crypto's Issues

Add Exchange specific Interface

  • Expected Feature: Add Exchange specific Interface
  • Reactive Crypto version: v1.0.2.RELEASE
  • JVM / Kotlin version:
  • OS version:

kraken orderbook stream synchronization error

  • Steps to reproduce:
    Missing orders in one direction when bid and ask come together in a orderbook update event.
[325,{"a":[["0.005420","105.29147842","1565079797.528316"]]},{"b":[["0.005350","565.76228800","1565079797.481863"]]},"book-10","ZEC/XBT"]
  • Exchange: Karaken
  • Reactive Crypto version: 0.2.3.RELEASE

New exchange bitstamp

  • Expected Feature: new exchange bitstamp
  • Reactive Crypto version:
  • JVM / Kotlin version:
  • OS version:

Coineal open order error

  • Actual behavior:
    Deserialize exception when empty open order

  • Steps to reproduce:

  • Exchange: coineal

  • Reactive Crypto version:

  • JVM / Kotlin version:

  • OS version:

OrderBook synchronization fails on reconnection

  • Expected behavior:

  • Actual behavior:
    OrderBook not updated when connection disconnected

  • Steps to reproduce:
    create depth stream and reconnect using Flux#retry

  • Exchange: Bitmax

  • Reactive Crypto version: 0.1.9.RELEASE

  • JVM / Kotlin version: 1.8

  • OS version:

trade api (order, cancel)

  • Expected Feature: trade api (order, cancel)
  • Reactive Crypto version: v1.0.1.RELEASE
  • JVM / Kotlin version:
  • OS version:

Add the dependency fails (Gradle builder)

Hi @namjug-kim ๐Ÿ˜€, I am getting gradle build warning and cannot access the contents of the library. Help me please ๐Ÿ™

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.github.namjug-kim.reactive-crypto:reactive-crypto-{exchange-name}:0.2.3-RELEASE.
Show Details
Affected Modules: app

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.github.namjug-kim.reactive-crypto:reactive-crypto-{exchange-name}:0.2.3-RELEASE.
Show Details
Affected Modules: app

Gradle :app
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
    id 'com.github.dcendents.android-maven'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.koshelek_ru"
        minSdkVersion 27
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    androidExtensions {
        experimental = true
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.github.namjug-kim.reactive-crypto:reactive-crypto-{exchange-name}:0.2.3-RELEASE'
    implementation 'com.google.android.material:material:1.2.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}


Gradle: project
buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Okex Korea ws client doean't work

  • Expected behavior:
  • Actual behavior:
  • Steps to reproduce:
  • Exchange: OKEX Korea
  • Reactive Crypto version:
  • JVM / Kotlin version:
  • OS version:

Okex Korea websocket change from custom to okex v3

Bithumb multiple pair subscribe issue

  • Expected behavior:
    able to subscribe to multiple pairs at Bithumb Exchange.

  • Actual behavior:
    Only last pair subscribed

  • Steps to reproduce:

  • Exchange: Bithumb

  • Reactive Crypto version:

  • JVM / Kotlin version:

  • OS version:

What is the best way to get continuous tick data?

Apparently, the code in the example does not work and I think it should be updated. Here is what I have:

while (true) {
            try {

                ExchangeWebsocketClient exchangeWebsocketClient = ExchangeClientFactory.websocket(ExchangeVendor.BINANCE);

                List<CurrencyPair> targetPairs = Collections.singletonList(CurrencyPair.parse("BTC", "USDT"));
                Flux<TickData> tickDataFlux = exchangeWebsocketClient.createTradeWebsocket(targetPairs);
//                .doOnNext(tickData -> System.out.println(tickData.getQuantity()))
//                .subscribe();
                while (true) {
                    TickData tickData = tickDataFlux.blockFirst();
                    System.out.println("time: " + System.currentTimeMillis());
                    System.out.println(tickData.getPrice());
                    System.out.println(tickData.getQuantity());
                    System.out.println("=======================");
                }
            } catch (Exception e) {
                StringWriter stringWriter = new StringWriter();
                    PrintWriter printWriter = new PrintWriter(stringWriter);
                    e.printStackTrace(printWriter);
                    testLogger.info(stringWriter.toString());
                    testLogger.info(e.getMessage());

            }
        }

Sorry if it should be obvious. I am a noob.

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.