diff --git a/xchange-kraken/src/main/java/info/bitrich/xchangestream/kraken/KrakenOrderBookUtils.java b/xchange-kraken/src/main/java/info/bitrich/xchangestream/kraken/KrakenOrderBookUtils.java index daa02dacd..0062f373a 100644 --- a/xchange-kraken/src/main/java/info/bitrich/xchangestream/kraken/KrakenOrderBookUtils.java +++ b/xchange-kraken/src/main/java/info/bitrich/xchangestream/kraken/KrakenOrderBookUtils.java @@ -29,6 +29,7 @@ public class KrakenOrderBookUtils { private static final String BID_UPDATE = "b"; private static final int EXPECTED_ORDER_BOOK_ARRAY_SIZE = 4; + private static final BigDecimal BIG_DECIMAL_1000 = new BigDecimal(1000); @SuppressWarnings("unchecked") public static KrakenOrderBook parse(List jsonParseResult) { @@ -90,7 +91,7 @@ public static KrakenPublicOrder extractKrakenPublicOrder(List list) { //TODO: The XChange Kraken orderbook timestamp is a seconds format since epoch. // But websocket order's timestamp is more accurate. It is required to improve the XChange Kraken for supporting higher precision. // XChange method to fix: org.knowm.xchange.kraken.KrakenAdapters.adaptOrders - new BigDecimal(list.get(2)).longValue() + new BigDecimal(list.get(2)).multiply(BIG_DECIMAL_1000).longValue() ); } diff --git a/xchange-kraken/src/test/java/info/bitrich/xchangestream/kraken/KrakenOrderBookParseTest.java b/xchange-kraken/src/test/java/info/bitrich/xchangestream/kraken/KrakenOrderBookParseTest.java index 076746836..a5133c925 100644 --- a/xchange-kraken/src/test/java/info/bitrich/xchangestream/kraken/KrakenOrderBookParseTest.java +++ b/xchange-kraken/src/test/java/info/bitrich/xchangestream/kraken/KrakenOrderBookParseTest.java @@ -30,11 +30,11 @@ public void testOrderBookSnapshot() throws IOException { KrakenPublicOrder firstAsk = krakenOrderBook.getAsk()[0]; Assert.assertEquals(0, new BigDecimal("8692").compareTo(firstAsk.getPrice())); Assert.assertEquals(0, new BigDecimal("2.01122372").compareTo(firstAsk.getVolume())); - Assert.assertEquals(1561120269L, firstAsk.getTimestamp()); + Assert.assertEquals(1561120269939L, firstAsk.getTimestamp()); KrakenPublicOrder firstBid = krakenOrderBook.getBid()[0]; Assert.assertEquals(0, new BigDecimal("8691.9").compareTo(firstBid.getPrice())); Assert.assertEquals(0, new BigDecimal("1.45612927").compareTo(firstBid.getVolume())); - Assert.assertEquals(1561120266L, firstBid.getTimestamp()); + Assert.assertEquals(1561120266647L, firstBid.getTimestamp()); } @Test @@ -53,6 +53,6 @@ public void testOrderBookUpdate() throws IOException { KrakenPublicOrder firstAsk = krakenOrderBook.getAsk()[0]; Assert.assertEquals(0, new BigDecimal("9618.6").compareTo(firstAsk.getPrice())); Assert.assertEquals(0, BigDecimal.ZERO.compareTo(firstAsk.getVolume())); - Assert.assertEquals(1561372908L, firstAsk.getTimestamp()); + Assert.assertEquals(1561372908562L, firstAsk.getTimestamp()); } }