From 28fbe693200124295f2c558af21063e22363795c Mon Sep 17 00:00:00 2001 From: Dolezal Zdenek Date: Fri, 14 Jul 2017 12:42:05 +0200 Subject: [PATCH] #11 Xchange dependency updated to latest SNAPSHOT --- pom.xml | 2 +- .../BitstampStreamingMarketDataService.java | 9 +++---- .../bitstamp/dto/BitstampOrderBook.java | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/dto/BitstampOrderBook.java diff --git a/pom.xml b/pom.xml index 74bc4e921..9950954fe 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ - 4.2.0 + 4.2.1-SNAPSHOT UTF-8 UTF-8 1.8 diff --git a/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/BitstampStreamingMarketDataService.java b/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/BitstampStreamingMarketDataService.java index 37b9b1718..7f897cbd4 100644 --- a/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/BitstampStreamingMarketDataService.java +++ b/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/BitstampStreamingMarketDataService.java @@ -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 { @@ -30,10 +31,10 @@ public Observable 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); }); } diff --git a/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/dto/BitstampOrderBook.java b/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/dto/BitstampOrderBook.java new file mode 100644 index 000000000..c7e1f80d3 --- /dev/null +++ b/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/dto/BitstampOrderBook.java @@ -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> bids; + private final List> asks; + + public BitstampOrderBook(@JsonProperty("bids") List> bids, @JsonProperty("asks") List> asks) { + this.bids = bids; + this.asks = asks; + } + + public List> getBids() { + return bids; + } + + public List> getAsks() { + return asks; + } +}