diff --git a/xchange-kucoin/example.http-client.private.env.json b/xchange-kucoin/example.http-client.private.env.json new file mode 100644 index 00000000000..977c974ecbe --- /dev/null +++ b/xchange-kucoin/example.http-client.private.env.json @@ -0,0 +1,6 @@ +{ + "default": { + "api_key": "replace_me", + "api_secret": "replace_me" + } +} \ No newline at end of file diff --git a/xchange-kucoin/http-client.env.json b/xchange-kucoin/http-client.env.json new file mode 100644 index 00000000000..ce9ca9b3115 --- /dev/null +++ b/xchange-kucoin/http-client.env.json @@ -0,0 +1,5 @@ +{ + "default": { + "api_host": "https://api.kucoin.com" + } +} \ No newline at end of file diff --git a/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/KucoinAdapters.java b/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/KucoinAdapters.java index acdcc8be87c..23d821a441e 100644 --- a/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/KucoinAdapters.java +++ b/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/KucoinAdapters.java @@ -41,7 +41,11 @@ import org.knowm.xchange.dto.marketdata.Trade; import org.knowm.xchange.dto.marketdata.Trades; import org.knowm.xchange.dto.marketdata.Trades.TradeSortType; -import org.knowm.xchange.dto.meta.*; +import org.knowm.xchange.dto.meta.CurrencyMetaData; +import org.knowm.xchange.dto.meta.ExchangeMetaData; +import org.knowm.xchange.dto.meta.FeeTier; +import org.knowm.xchange.dto.meta.InstrumentMetaData; +import org.knowm.xchange.dto.meta.WalletHealth; import org.knowm.xchange.dto.trade.LimitOrder; import org.knowm.xchange.dto.trade.MarketOrder; import org.knowm.xchange.dto.trade.StopOrder; @@ -101,7 +105,9 @@ public static List adaptAllTickers(AllTickersResponse allTickersResponse new Ticker.Builder() .instrument(adaptCurrencyPair(ticker.getSymbol())) .bid(ticker.getBuy()) + .bidSize(ticker.getBestBidSize()) .ask(ticker.getSell()) + .askSize(ticker.getBestAskSize()) .last(ticker.getLast()) .high(ticker.getHigh()) .low(ticker.getLow()) diff --git a/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/dto/response/AllTickersTickerResponse.java b/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/dto/response/AllTickersTickerResponse.java index 44d52a41d74..94065b30abd 100644 --- a/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/dto/response/AllTickersTickerResponse.java +++ b/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/dto/response/AllTickersTickerResponse.java @@ -11,7 +11,9 @@ public class AllTickersTickerResponse { private BigDecimal last; private BigDecimal low; private BigDecimal buy; + private BigDecimal bestBidSize; private BigDecimal sell; + private BigDecimal bestAskSize; private BigDecimal changePrice; private BigDecimal changeRate; private BigDecimal volValue; diff --git a/xchange-kucoin/src/test/java/org/knowm/xchange/kucoin/KucoinMarketDataServiceIntegration.java b/xchange-kucoin/src/test/java/org/knowm/xchange/kucoin/KucoinMarketDataServiceIntegration.java index c3c8e47ab6e..569e6de48dc 100644 --- a/xchange-kucoin/src/test/java/org/knowm/xchange/kucoin/KucoinMarketDataServiceIntegration.java +++ b/xchange-kucoin/src/test/java/org/knowm/xchange/kucoin/KucoinMarketDataServiceIntegration.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotEquals; import static org.knowm.xchange.kucoin.KucoinMarketDataService.PARAM_PARTIAL_SHALLOW_ORDERBOOK; +import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.ZoneOffset; @@ -76,6 +77,25 @@ public void testGetTicker() throws Exception { checkTimestamp(ticker.getTimestamp()); } + + @Test + public void valid_tickers() throws IOException { + List tickers = exchange().getMarketDataService().getTickers(null); + assertThat(tickers).isNotEmpty(); + + assertThat(tickers).allSatisfy(ticker -> { + assertThat(ticker.getInstrument()).isNotNull(); + assertThat(ticker.getLast()).isPositive(); + + assertThat(ticker.getBidSize()).isPositive(); + assertThat(ticker.getAskSize()).isPositive(); + + assertThat(ticker.getAsk()).isPositive(); + assertThat(ticker.getBid()).isPositive(); + assertThat(ticker.getBid()).isLessThan(ticker.getAsk()); + }); + } + @Test public void testGetTickers() throws Exception { KucoinExchange exchange = exchange(); diff --git a/xchange-kucoin/src/test/resources/http/market.http b/xchange-kucoin/src/test/resources/http/market.http new file mode 100644 index 00000000000..e7056b9bc50 --- /dev/null +++ b/xchange-kucoin/src/test/resources/http/market.http @@ -0,0 +1,8 @@ +### Get Ticker +GET {{api_host}}/api/v1/market/orderbook/level1?symbol=BTC-USDT + +### Get All Tickers +GET {{api_host}}/api/v1/market/allTickers + +### Get 24hr Stats +GET {{api_host}}/api/v1/market/stats?symbol=BTC-USDT