Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Commit

Permalink
#11 Xchange dependency updated to latest SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolezal Zdenek authored and Dolezal Zdenek committed Jul 14, 2017
1 parent 5096ef3 commit 28fbe69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</repositories>

<properties>
<xchange.version>4.2.0</xchange.version>
<xchange.version>4.2.1-SNAPSHOT</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
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import info.bitrich.xchangestream.bitstamp.dto.BitstampOrderBook;
import info.bitrich.xchangestream.bitstamp.dto.BitstampWebSocketTransaction;
import info.bitrich.xchangestream.core.StreamingMarketDataService;
import info.bitrich.xchangestream.service.pusher.PusherStreamingService;
import io.reactivex.Observable;
import org.knowm.xchange.bitstamp.BitstampAdapters;
import org.knowm.xchange.bitstamp.dto.marketdata.BitstampOrderBook;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.marketdata.Trade;
import org.knowm.xchange.exceptions.NotAvailableFromExchangeException;

import java.util.Date;

public class BitstampStreamingMarketDataService implements StreamingMarketDataService {
Expand All @@ -30,10 +31,10 @@ public Observable<OrderBook> getOrderBook(CurrencyPair currencyPair, Object... a
.map(s -> {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
BitstampOrderBook bitstampOrderBook = mapper.readValue(s, BitstampOrderBook.class);
bitstampOrderBook = new BitstampOrderBook(new Date().getTime()/1000L, bitstampOrderBook.getBids(), bitstampOrderBook.getAsks());
BitstampOrderBook orderBook = mapper.readValue(s, BitstampOrderBook.class);
org.knowm.xchange.bitstamp.dto.marketdata.BitstampOrderBook bitstampOrderBook = new org.knowm.xchange.bitstamp.dto.marketdata.BitstampOrderBook(new Date().getTime(), orderBook.getBids(), orderBook.getAsks());

return BitstampAdapters.adaptOrderBook(bitstampOrderBook, currencyPair, 1000);
return BitstampAdapters.adaptOrderBook(bitstampOrderBook, currencyPair);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package info.bitrich.xchangestream.bitstamp.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigDecimal;
import java.util.List;

public class BitstampOrderBook {
private final List<List<BigDecimal>> bids;
private final List<List<BigDecimal>> asks;

public BitstampOrderBook(@JsonProperty("bids") List<List<BigDecimal>> bids, @JsonProperty("asks") List<List<BigDecimal>> asks) {
this.bids = bids;
this.asks = asks;
}

public List<List<BigDecimal>> getBids() {
return bids;
}

public List<List<BigDecimal>> getAsks() {
return asks;
}
}

0 comments on commit 28fbe69

Please sign in to comment.