Skip to content

Commit

Permalink
Merge pull request #7 from bitrich-info/develop
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
pchertalev committed Jan 14, 2019
2 parents 3780aa4 + e27763b commit b992cbf
Show file tree
Hide file tree
Showing 33 changed files with 184 additions and 172 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ GDAX authenticated live updates are not yet supported, hopefully it will be adde

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.
- [XChange-Trade-Bot](https://github.com/yurivin/xchange-trade-bot) by yurivin
- [Crypto Websockets](https://github.com/firepol/crypto-websockets) by firepol

## License
Copyright 2017 Zdenek Dolezal, Michal Oprendek
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>info.bitrich.xchange-stream</groupId>
<artifactId>xchange-stream-parent</artifactId>
<packaging>pom</packaging>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>

<modules>
<module>xchange-stream-core</module>
Expand All @@ -19,7 +19,7 @@
<module>xchange-okcoin</module>
<module>xchange-poloniex</module>
<module>xchange-coinmate</module>
<module>xchange-gdax</module>
<module>xchange-coinbasepro</module>
<module>xchange-bitfinex</module>
<module>xchange-bitmex</module>
<module>xchange-poloniex2</module>
Expand Down Expand Up @@ -80,7 +80,7 @@
</repositories>

<properties>
<xchange.version>4.3.11</xchange.version>
<xchange.version>4.3.13</xchange.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion service-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion service-netty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion service-pubnub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion service-pusher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion service-wamp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xchange-binance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xchange-bitfinex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void handleMessage(JsonNode message) {
subscribedChannels.remove(channelId);
} else if (event.textValue().equals(ERROR)) {
if (message.get("code").asInt() == SUBSCRIPTION_FAILED) {
LOG.error("Error with message: " + message.get("msg"));
LOG.error("Error with message: " + message.get("symbol") + " " + message.get("msg"));
return;
}
super.handleError(message, new ExchangeException("Error code: " + message.get("code").asText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public BitfinexTrade toBitfinexTrade() {
} else {
type = "buy";
}

return new BitfinexTrade(price, amount, timestamp / 1000, "bitfinex", tradeId, type);
return new BitfinexTrade(price, amount.abs(), timestamp / 1000, "bitfinex", tradeId, type);
}
}
2 changes: 1 addition & 1 deletion xchange-bitflyer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xchange-bitmex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xchange-bitstamp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xchange-cexio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
6 changes: 3 additions & 3 deletions xchange-gdax/pom.xml → xchange-coinbasepro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<parent>
<artifactId>xchange-stream-parent</artifactId>
<groupId>info.bitrich.xchange-stream</groupId>
<version>4.3.12-SNAPSHOT</version>
<version>4.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>xchange-gdax</artifactId>
<artifactId>xchange-coinbasepro</artifactId>

<dependencies>
<dependency>
Expand All @@ -22,7 +22,7 @@
</dependency>
<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-gdax</artifactId>
<artifactId>xchange-coinbasepro</artifactId>
<version>${xchange.version}</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package info.bitrich.xchangestream.gdax;
package info.bitrich.xchangestream.coinbasepro;

import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.coinbasepro.CoinbaseProExchange;
import org.knowm.xchange.coinbasepro.dto.account.CoinbaseProWebsocketAuthData;
import org.knowm.xchange.coinbasepro.service.CoinbaseProAccountServiceRaw;

import info.bitrich.xchangestream.core.ProductSubscription;
import info.bitrich.xchangestream.core.StreamingExchange;
import info.bitrich.xchangestream.core.StreamingMarketDataService;
import info.bitrich.xchangestream.service.netty.WebSocketClientHandler;
import io.reactivex.Completable;
import io.reactivex.Observable;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.gdax.GDAXExchange;
import org.knowm.xchange.gdax.dto.account.GDAXWebsocketAuthData;
import org.knowm.xchange.gdax.service.GDAXAccountServiceRaw;

/**
* GDAX Streaming Exchange. Connects to live WebSocket feed.
* CoinbasePro Streaming Exchange. Connects to live WebSocket feed.
*/
public class GDAXStreamingExchange extends GDAXExchange implements StreamingExchange {
private static final String API_URI = "wss://ws-feed.gdax.com";
public class CoinbaseProStreamingExchange extends CoinbaseProExchange implements StreamingExchange {
private static final String API_URI = "wss://ws-feed.pro.coinbase.com";

private GDAXStreamingService streamingService;
private GDAXStreamingMarketDataService streamingMarketDataService;
private CoinbaseProStreamingService streamingService;
private CoinbaseProStreamingMarketDataService streamingMarketDataService;

public GDAXStreamingExchange() { }
public CoinbaseProStreamingExchange() { }

@Override
protected void initServices() {
Expand All @@ -32,18 +33,18 @@ public Completable connect(ProductSubscription... args) {
if (args == null || args.length == 0)
throw new UnsupportedOperationException("The ProductSubscription must be defined!");
ExchangeSpecification exchangeSpec = getExchangeSpecification();
this.streamingService = new GDAXStreamingService(API_URI, () -> authData(exchangeSpec));
this.streamingMarketDataService = new GDAXStreamingMarketDataService(this.streamingService);
this.streamingService = new CoinbaseProStreamingService(API_URI, () -> authData(exchangeSpec));
this.streamingMarketDataService = new CoinbaseProStreamingMarketDataService(streamingService);
streamingService.subscribeMultipleCurrencyPairs(args);

return streamingService.connect();
}

private GDAXWebsocketAuthData authData(ExchangeSpecification exchangeSpec) {
GDAXWebsocketAuthData authData = null;
private CoinbaseProWebsocketAuthData authData(ExchangeSpecification exchangeSpec) {
CoinbaseProWebsocketAuthData authData = null;
if ( exchangeSpec.getApiKey() != null ) {
try {
GDAXAccountServiceRaw rawAccountService = (GDAXAccountServiceRaw) getAccountService();
CoinbaseProAccountServiceRaw rawAccountService = (CoinbaseProAccountServiceRaw) getAccountService();
authData = rawAccountService.getWebsocketAuthData();
}
catch (Exception e) {
Expand All @@ -56,7 +57,7 @@ private GDAXWebsocketAuthData authData(ExchangeSpecification exchangeSpec) {

@Override
public Completable disconnect() {
GDAXStreamingService service = this.streamingService;
CoinbaseProStreamingService service = streamingService;
streamingService = null;
streamingMarketDataService = null;
return service.disconnect();
Expand Down
Loading

0 comments on commit b992cbf

Please sign in to comment.