Giter VIP home page Giter VIP logo

afaslan / xchange-stream Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitrich-info/xchange-stream

0.0 1.0 0.0 405 KB

XChange-stream is a Java library providing a simple and consistent streaming API for interacting with Bitcoin and other crypto currency exchanges via WebSocket protocol. It is build on top of of XChange library providing new interfaces for streaming API. User can subscribe for live updates via reactive streams of RxJava library.

License: Apache License 2.0

Shell 1.69% Batchfile 1.31% Java 97.01%

xchange-stream's Introduction

XChange-stream Build Status

XChange-stream is a Java library providing a simple and consistent streaming API for interacting with Bitcoin and other crypto currency exchanges via WebSocket protocol.

It is build on top of the XChange library providing new interfaces for the exchanges' streaming APIs. Users can subscribe for live updates via reactive streams of RxJava library.

Why use it?

  • Easy to use - no need to hack WebSocket and other backends.
  • Consistent & simple API across all implemented exchanges.
  • Extends well-known & active Java library XChange.
  • Reactive streams are fun to work with.
  • Modular extensibility.

Getting started

Include in your project

Xchange-stream is on Maven Central. You will need xchange-stream-core dependency and xchange-XYZ where XYZ is supported exchange (eg. xchange-bitstamp). Add the following into your pom.xml.

Maven

<dependency>
    <groupId>info.bitrich.xchange-stream</groupId>
    <artifactId>xchange-stream-core</artifactId>
    <version>x.y.z</version>
</dependency>

<dependency>
    <groupId>info.bitrich.xchange-stream</groupId>
    <artifactId>xchange-XYZ</artifactId>
    <version>x.y.z</version>
</dependency>

Maven Central

For snapshots version (built from develop branch), add the following repository to your pom.xml file.

<repository>
  <id>sonatype-oss-snapshot</id>
  <snapshots/>
  <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>

Versioning

XChange-stream follows major and minor version from XChange library. So version 4.2.x is based on latest 4.2. release of XChange.

Example

Use the same library as XChange but instead of ExchangeFactory use StreamingExchangeFactory that creates StreamingExchange instead of Exchange. Then you can call getStreamingMarketDataService to subscribe to trade data.

StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(BitstampStreamingExchange.class.getName());

// Connect to the Exchange WebSocket API. Blocking wait for the connection.
exchange.connect().blockingAwait();

// Subscribe to live trades update.
exchange.getStreamingMarketDataService()
        .getTrades(CurrencyPair.BTC_USD)
        .subscribe(trade -> {
            LOG.info("Incoming trade: {}", trade);
        }, throwable -> {
            LOG.error("Error in subscribing trades.", throwable);
        });

// Subscribe order book data with the reference to the subscription.
Disposable subscription = exchange.getStreamingMarketDataService()
                                  .getOrderBook(CurrencyPair.BTC_USD)
                                  .subscribe(orderBook -> {
                                       // Do something
                                  });

// Unsubscribe from data order book.
subscription.dispose();

// Disconnect from exchange (non-blocking)
exchange.disconnect().subscribe(() -> LOG.info("Disconnected from the Exchange"));

More information about reactive streams can be found at RxJava wiki.

What is supported

Listening for live updates of

Exchange order books trades tickers
Binance โœ”๏ธ ๐Ÿšง โœ”๏ธ
Bitfinex โœ”๏ธ โœ”๏ธ โœ”๏ธ
Bitflyer โœ”๏ธ โœ”๏ธ โœ”๏ธ
BitMEX โœ”๏ธ โœ”๏ธ โœ”๏ธ
Bitstamp โœ”๏ธ โœ”๏ธ โŒ
Coinmate โœ”๏ธ โœ”๏ธ โŒ
OKCoin โœ”๏ธ โœ”๏ธ โœ”๏ธ
OKEx โœ”๏ธ โœ”๏ธ โœ”๏ธ
Poloniex โœ”๏ธ โœ”๏ธ โœ”๏ธ
GDAX โœ”๏ธ โœ”๏ธ โœ”๏ธ
Gemini โœ”๏ธ โœ”๏ธ โŒ
Wex โœ”๏ธ โœ”๏ธ โŒ
  • โœ”๏ธ - implemented
  • ๐Ÿšง - missing but can be implemented
  • โŒ - not supported by the exchange

GDAX authenticated live updates are not yet supported, hopefully it will be added in the near future.

If you missing a specific exchange implementation, feel free to propose a pull request or open an issue with some sweet BTC bounty.

License

Copyright 2017 Zdenek Dolezal, Michal Oprendek

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

xchange-stream's People

Contributors

dozd avatar lukaszaoralek avatar lucarosellini avatar alphafoobar avatar scionaltera avatar traviscollins avatar daniel-cohen avatar janakerman avatar langchristian96 avatar kaiserfr avatar nodarret avatar altmind avatar obsessiveorange avatar boppleton avatar caleb-allen avatar badgerwithagun avatar leonidshamis avatar tobcar avatar aleks-azen avatar bobeagle avatar bryantharris avatar hkscfreak avatar hwiceberg avatar moritzhabegger avatar nihiluis avatar octoberfestuser avatar pchertalev avatar roeiba avatar undecaf avatar

Watchers

Ali Fuat Arslan 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.