From aedf72910e96582dc49e17363af1a00a95921848 Mon Sep 17 00:00:00 2001 From: Dmitri Karpovich Date: Mon, 26 Aug 2024 23:50:10 +0200 Subject: [PATCH 1/2] [gateio-v4] Add integration test --- .../GateioMarketDataServiceIntegration.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioMarketDataServiceIntegration.java b/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioMarketDataServiceIntegration.java index a175ac19db2..cdff7ac9114 100644 --- a/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioMarketDataServiceIntegration.java +++ b/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioMarketDataServiceIntegration.java @@ -2,8 +2,15 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.io.IOException; +import java.util.List; +import org.apache.commons.lang3.ObjectUtils; import org.junit.jupiter.api.Test; import org.knowm.xchange.ExchangeFactory; +import org.knowm.xchange.currency.CurrencyPair; +import org.knowm.xchange.dto.Order.OrderType; +import org.knowm.xchange.dto.marketdata.OrderBook; +import org.knowm.xchange.dto.marketdata.Ticker; import org.knowm.xchange.dto.meta.ExchangeHealth; import org.knowm.xchange.gateio.GateioExchange; @@ -17,4 +24,42 @@ void exchange_health() { assertThat(actual).isEqualTo(ExchangeHealth.ONLINE); } + + @Test + 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()).isNotNull(); + if (ObjectUtils.allNotNull(ticker.getBid(), ticker.getAsk()) && ticker.getBid().signum() > 0 && ticker.getAsk().signum() > 0) { + assertThat(ticker.getBid()).isLessThan(ticker.getAsk()); + } + }); + } + + + @Test + void valid_orderbook() throws IOException { + OrderBook orderBook = exchange.getMarketDataService().getOrderBook(CurrencyPair.BTC_USDT); + + assertThat(orderBook.getBids()).isNotEmpty(); + assertThat(orderBook.getAsks()).isNotEmpty(); + + assertThat(orderBook.getAsks().get(0).getLimitPrice()).isGreaterThan(orderBook.getBids().get(0).getLimitPrice()); + + assertThat(orderBook.getBids()).allSatisfy(limitOrder -> { + assertThat(limitOrder.getInstrument()).isEqualTo(CurrencyPair.BTC_USDT); + assertThat(limitOrder.getType()).isEqualTo(OrderType.BID); + }); + + assertThat(orderBook.getAsks()).allSatisfy(limitOrder -> { + assertThat(limitOrder.getInstrument()).isEqualTo(CurrencyPair.BTC_USDT); + assertThat(limitOrder.getType()).isEqualTo(OrderType.ASK); + }); + + } + + } \ No newline at end of file From 26a24a88eeebdcf911f78d89f8bc50c366b75f99 Mon Sep 17 00:00:00 2001 From: Dmitri Karpovich Date: Mon, 26 Aug 2024 23:50:25 +0200 Subject: [PATCH 2/2] [gateio-v4] Add more http requests --- xchange-gateio-v4/src/test/resources/rest/spot.http | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xchange-gateio-v4/src/test/resources/rest/spot.http b/xchange-gateio-v4/src/test/resources/rest/spot.http index 325625fdc7b..f4e0c246a4c 100644 --- a/xchange-gateio-v4/src/test/resources/rest/spot.http +++ b/xchange-gateio-v4/src/test/resources/rest/spot.http @@ -11,6 +11,19 @@ Timestamp: {{timestamp}} Content-Type: application/json +### List spot accounts +< {% + import {gen_sign} from 'sign.js' + gen_sign("GET", request); +%} + +GET {{api_v4}}/spot/accounts +KEY: {{api_key}} +SIGN: {{sign}} +Timestamp: {{timestamp}} +Content-Type: application/json + + ### Query account book < {% import {gen_sign} from 'sign.js'