Skip to content
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.
Branch: develop
Clone or download
badgerwithagun Merge pull request #347 from bitrich-info/dependabot/maven/org.apache…
….logging.log4j-log4j-slf4j-impl-2.12.0

Bump log4j-slf4j-impl from 2.11.2 to 2.12.0
Latest commit a6d95ea Jul 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dependabot Dependabot config Mar 19, 2019
.mvn/wrapper Added maven wrapper. (#83) Jan 24, 2018
service-core [maven-release-plugin] prepare for next development iteration Jun 27, 2019
service-netty Bump netty-all from 4.1.36.Final to 4.1.37.Final Jul 15, 2019
service-pubnub [maven-release-plugin] prepare for next development iteration Jun 27, 2019
service-pusher [maven-release-plugin] prepare for next development iteration Jun 27, 2019
service-wamp Bump netty-handler from 4.1.36.Final to 4.1.37.Final Jul 15, 2019
xchange-bankera Revert previous changes Jan 24, 2019
xchange-binance [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-bitfinex Merge branch 'develop' into develop Jun 27, 2019
xchange-bitflyer [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-bitmex Bump fluent-hc from 4.5.5 to 4.5.9 Jul 15, 2019
xchange-bitstamp [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-cexio [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-coinbasepro [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-coinmate [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-gemini Merge branch 'develop' into develop Jun 27, 2019
xchange-hitbtc [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-kraken #279 Kraken WebSocket Implementation: review fixes Jun 28, 2019
xchange-okcoin [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-poloniex [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-poloniex2 Merge branch 'develop' into develop Jun 27, 2019
xchange-stream-core [maven-release-plugin] prepare for next development iteration Jun 27, 2019
xchange-wex [maven-release-plugin] prepare for next development iteration Jun 27, 2019
.gitattributes Initial commit. Jan 16, 2017
.gitignore [Cexio] Add new exchange with private streaming (#147) Apr 4, 2018
.travis.yml Travis configuration fix. Feb 11, 2017
LICENSE Initial commit Jan 17, 2017
README.md Add Orko to open source projects list (#335) Jun 21, 2019
mvnw Added maven wrapper. (#83) Jan 24, 2018
mvnw.cmd Added maven wrapper. (#83) Jan 24, 2018
pom.xml Bump log4j-slf4j-impl from 2.11.2 to 2.12.0 Jul 16, 2019

README.md

XChange-stream Build Status

MAINTAINER WANTED: If anyone would like contribute to this project and become a maintainer, let me know via message. This project would deserve more time than I have.

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 notes
Binance ✔️ ✔️ ✔️
Bitfinex ✔️ ✔️ ✔️
Bitflyer ✔️ ✔️ ✔️
BitMEX ✔️ ✔️ ✔️ We are short of maintainers able to review pull requests and provide support for Bitmex, so there is a backlog of pull requests and support is likely broken. Can you help?
Bitstamp ✔️ ✔️
CEX.IO ✔️ New support, not widely tested
Coinbase Pro ✔️ ✔️ ✔️
Coinmate ✔️ ✔️
OKCoin ✔️ ✔️ ✔️
OKEx ✔️ ✔️ ✔️
Poloniex ✔️ ✔️ ✔️
Gemini ✔️ ✔️
Wex ✔️ ✔️
  • ✔️ - implemented
  • 🚧 - missing but can be implemented
  • - not supported by the exchange

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

Open Source Projects Using XChange-Stream

This is an, not so complete, list of projects that use XChange-Stream, feel free to add your project below.

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.

You can’t perform that action at this time.