diff --git a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/Coinex.java b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/Coinex.java index 07d07ec2e89..40600c89088 100644 --- a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/Coinex.java +++ b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/Coinex.java @@ -37,9 +37,7 @@ CoinexResponse singleMarketStatistics( @GET @Path("v2/maintain/info") - CoinexResponse> maintainInfo() - throws IOException, CoinexException; - + CoinexResponse> maintainInfo() throws IOException, CoinexException; @GET @Path("v2/spot/market") diff --git a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/dto/marketdata/CoinexMaintainInfo.java b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/dto/marketdata/CoinexMaintainInfo.java index b0c186e56bf..5f898916eff 100644 --- a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/dto/marketdata/CoinexMaintainInfo.java +++ b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/dto/marketdata/CoinexMaintainInfo.java @@ -13,25 +13,24 @@ @Jacksonized public class CoinexMaintainInfo { - @JsonProperty("started_at") - private Instant startTime; + @JsonProperty("started_at") + private Instant startTime; - @JsonProperty("ended_at") - private Instant endTime; + @JsonProperty("ended_at") + private Instant endTime; - @JsonProperty("scope") - private List scope; + @JsonProperty("scope") + private List scope; - @JsonProperty("announce_enabled") - private Boolean announceEnabled; + @JsonProperty("announce_enabled") + private Boolean announceEnabled; - @JsonProperty("announce_url") - private URI announceUrl; + @JsonProperty("announce_url") + private URI announceUrl; - @JsonProperty("protect_duration_start") - private Instant protectStart; - - @JsonProperty("protect_duration_end") - private Instant protectEnd; + @JsonProperty("protect_duration_start") + private Instant protectStart; + @JsonProperty("protect_duration_end") + private Instant protectEnd; } diff --git a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataService.java b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataService.java index 80b8bea7def..e96183e4af4 100644 --- a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataService.java +++ b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataService.java @@ -40,20 +40,20 @@ public ExchangeHealth getExchangeHealth() { try { List coinexMaintainInfos = getCoinexMaintainInfo(); - for (CoinexMaintainInfo coinexMaintainInfo: coinexMaintainInfos) { + for (CoinexMaintainInfo coinexMaintainInfo : coinexMaintainInfos) { Instant now = Instant.now(Config.getInstance().getClock()); - if (ObjectUtils.allNotNull(coinexMaintainInfo.getStartTime(), - coinexMaintainInfo.getEndTime())) { - if (now.isAfter(coinexMaintainInfo.getStartTime()) && now.isBefore( - coinexMaintainInfo.getEndTime())) { + if (ObjectUtils.allNotNull( + coinexMaintainInfo.getStartTime(), coinexMaintainInfo.getEndTime())) { + if (now.isAfter(coinexMaintainInfo.getStartTime()) + && now.isBefore(coinexMaintainInfo.getEndTime())) { return ExchangeHealth.OFFLINE; } } - if (ObjectUtils.allNotNull(coinexMaintainInfo.getProtectStart(), - coinexMaintainInfo.getProtectEnd())) { - if (now.isAfter(coinexMaintainInfo.getProtectStart()) && now.isBefore( - coinexMaintainInfo.getProtectEnd())) { + if (ObjectUtils.allNotNull( + coinexMaintainInfo.getProtectStart(), coinexMaintainInfo.getProtectEnd())) { + if (now.isAfter(coinexMaintainInfo.getProtectStart()) + && now.isBefore(coinexMaintainInfo.getProtectEnd())) { return ExchangeHealth.OFFLINE; } } @@ -66,7 +66,6 @@ public ExchangeHealth getExchangeHealth() { return ExchangeHealth.ONLINE; } - @Override public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException { return getTicker((Instrument) currencyPair, args); diff --git a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceRaw.java b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceRaw.java index ee0b69a11da..c84f6c217de 100644 --- a/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceRaw.java +++ b/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceRaw.java @@ -22,12 +22,10 @@ public CoinexMarketDataServiceRaw(CoinexExchange exchange) { super(exchange); } - public List getCoinexMaintainInfo() throws IOException { return coinex.maintainInfo().getData(); } - public List getAllCoinexChainInfos() throws IOException { return new ArrayList<>(coinex.allChainInfos().getData().values()); } diff --git a/xchange-coinex/src/test/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceIntegration.java b/xchange-coinex/src/test/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceIntegration.java index aaa1ea14335..c32013b3798 100644 --- a/xchange-coinex/src/test/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceIntegration.java +++ b/xchange-coinex/src/test/java/org/knowm/xchange/coinex/service/CoinexMarketDataServiceIntegration.java @@ -19,10 +19,10 @@ class CoinexMarketDataServiceIntegration { @Test public void exchange_health() { - assertThat(exchange.getMarketDataService().getExchangeHealth()).isEqualTo(ExchangeHealth.ONLINE); + assertThat(exchange.getMarketDataService().getExchangeHealth()) + .isEqualTo(ExchangeHealth.ONLINE); } - @Test void valid_tickers() throws IOException { List tickers = exchange.getMarketDataService().getTickers(null); diff --git a/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamClientOid.java b/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamClientOid.java index 1bf27c7be7c..5d3cf768284 100644 --- a/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamClientOid.java +++ b/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamClientOid.java @@ -1,12 +1,9 @@ package org.knowm.xchange.service.trade.params; -/** - * {@link TradeHistoryParams} with client order id as param - */ +/** {@link TradeHistoryParams} with client order id as param */ public interface TradeHistoryParamClientOid extends TradeHistoryParams { String getClientOid(); void setClientOid(String clientOid); - } diff --git a/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamOrderId.java b/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamOrderId.java index da9485ed614..b0134adeaea 100644 --- a/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamOrderId.java +++ b/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamOrderId.java @@ -1,12 +1,9 @@ package org.knowm.xchange.service.trade.params; -/** - * {@link TradeHistoryParams} with order id as param - */ +/** {@link TradeHistoryParams} with order id as param */ public interface TradeHistoryParamOrderId extends TradeHistoryParams { String getOrderId(); void setOrderId(String orderId); - } diff --git a/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamTransactionId.java b/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamTransactionId.java index bc6ce2d2254..570f7966120 100644 --- a/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamTransactionId.java +++ b/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/TradeHistoryParamTransactionId.java @@ -1,8 +1,6 @@ package org.knowm.xchange.service.trade.params; -/** - * {@link TradeHistoryParams} with id of single trade as param - */ +/** {@link TradeHistoryParams} with id of single trade as param */ public interface TradeHistoryParamTransactionId extends TradeHistoryParams { String getTransactionId(); diff --git a/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/service/GateioTradeService.java b/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/service/GateioTradeService.java index f86e2421b26..c5983b1fc9c 100644 --- a/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/service/GateioTradeService.java +++ b/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/service/GateioTradeService.java @@ -40,10 +40,11 @@ public GateioTradeService(GateioExchange exchange) { public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException { Validate.isInstanceOf(InstrumentParam.class, params); Instrument instrument = ((InstrumentParam) params).getInstrument(); - List limitOrders = listOrders(instrument, OrderStatus.OPEN).stream() - .map(GateioAdapters::toOrder) - .map(LimitOrder.class::cast) - .collect(Collectors.toList()); + List limitOrders = + listOrders(instrument, OrderStatus.OPEN).stream() + .map(GateioAdapters::toOrder) + .map(LimitOrder.class::cast) + .collect(Collectors.toList()); return new OpenOrders(limitOrders); } diff --git a/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioTradeServiceTest.java b/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioTradeServiceTest.java index 165868fb703..5fc3d33fa91 100644 --- a/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioTradeServiceTest.java +++ b/xchange-gateio-v4/src/test/java/org/knowm/xchange/gateio/service/GateioTradeServiceTest.java @@ -178,7 +178,8 @@ void open_orders() throws IOException { .build(); OpenOrders openOrders = - gateioTradeService.getOpenOrders(new DefaultOpenOrdersParamInstrument(CurrencyPair.BTC_USDT)); + gateioTradeService.getOpenOrders( + new DefaultOpenOrdersParamInstrument(CurrencyPair.BTC_USDT)); assertThat(openOrders.getOpenOrders()).hasSize(1); assertThat(openOrders.getOpenOrders()).first().usingRecursiveComparison().isEqualTo(expected); } diff --git a/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java b/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java index 20a7075e7c2..acdf25317e2 100644 --- a/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java +++ b/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java @@ -96,7 +96,6 @@ public class BinanceStreamingMarketDataService implements StreamingMarketDataSer orderBookRawUpdatesSubscriptions; private Observable> allRollingWindowTickerSubscriptions; - /** * A scheduler for initialisation of binance order book snapshots, which is delegated to a * dedicated thread in order to avoid blocking of the Web Socket threads. @@ -217,15 +216,19 @@ public Observable getRawTicker(Instrument instrument) { instrument, s -> triggerObservableBody(rawTickerStream(instrument)).share()); } - public Observable rollingWindow(Instrument instrument, KlineInterval windowSize) { + public Observable rollingWindow( + Instrument instrument, KlineInterval windowSize) { if (!service.isLiveSubscriptionEnabled() && !service.getProductSubscription().getTicker().contains(instrument)) { throw new UpFrontSubscriptionRequiredException(); } - if(windowSize.equals(KlineInterval.h1) || windowSize.equals(KlineInterval.h4) || windowSize.equals(KlineInterval.d1)) { + if (windowSize.equals(KlineInterval.h1) + || windowSize.equals(KlineInterval.h4) + || windowSize.equals(KlineInterval.d1)) { return rollingWindowTickerSubscriptions.computeIfAbsent( - instrument, s -> triggerObservableBody(rollingWindowStream(instrument, windowSize)).share()); - }else { + instrument, + s -> triggerObservableBody(rollingWindowStream(instrument, windowSize)).share()); + } else { throw new UnsupportedOperationException("RollingWindow not supported for other window size!"); } } @@ -234,13 +237,16 @@ public Observable> allRollingWindow(KlineInterval windowS if (!service.isLiveSubscriptionEnabled()) { throw new UpFrontSubscriptionRequiredException(); } - if(windowSize.equals(KlineInterval.h1) || windowSize.equals(KlineInterval.h4) || windowSize.equals(KlineInterval.d1)) { - if(null != allRollingWindowTickerSubscriptions){ + if (windowSize.equals(KlineInterval.h1) + || windowSize.equals(KlineInterval.h4) + || windowSize.equals(KlineInterval.d1)) { + if (null != allRollingWindowTickerSubscriptions) { return allRollingWindowTickerSubscriptions.share(); } - allRollingWindowTickerSubscriptions = triggerObservableBody(allRollingWindowStream(windowSize)).share(); + allRollingWindowTickerSubscriptions = + triggerObservableBody(allRollingWindowStream(windowSize)).share(); return allRollingWindowTickerSubscriptions; - }else { + } else { throw new UnsupportedOperationException("RollingWindow not supported for other window size!"); } } @@ -405,7 +411,6 @@ public void unsubscribeKline(Instrument instrument, KlineInterval klineInterval) unsubscribe(instrument, KLINE, klineInterval); } - public void unsubscribeAllRollingWindow(KlineInterval klineInterval) { unsubscribe(null, TICKER_WINDOW, klineInterval); } @@ -436,9 +441,9 @@ private void unsubscribe( tickerSubscriptions.remove(instrument); break; case TICKER_WINDOW: - if(null == instrument){ + if (null == instrument) { allRollingWindowTickerSubscriptions = null; - }else { + } else { rollingWindowTickerSubscriptions.remove(instrument); } break; @@ -504,11 +509,18 @@ private Observable rawTickerStream(Instrument instrument) { .map(transaction -> transaction.getData().getTicker()); } - private Observable rollingWindowStream(Instrument instrument, KlineInterval windowSize) { + private Observable rollingWindowStream( + Instrument instrument, KlineInterval windowSize) { return this.service - .subscribeChannel(this.getChannelPrefix(instrument) + "@" + BinanceSubscriptionType.TICKER_WINDOW.getType() + windowSize.code(), new Object[0]) + .subscribeChannel( + this.getChannelPrefix(instrument) + + "@" + + BinanceSubscriptionType.TICKER_WINDOW.getType() + + windowSize.code(), + new Object[0]) .map( - (it) -> this.readTransaction(it, TICKER_TYPE, "ticker")) + (it) -> + this.readTransaction(it, TICKER_TYPE, "ticker")) .filter( transaction -> BinanceAdapters.adaptSymbol( @@ -519,10 +531,18 @@ private Observable rollingWindowStream(Instrument instrument, private Observable> allRollingWindowStream(KlineInterval windowSize) { return this.service - .subscribeChannel("!" + BinanceSubscriptionType.TICKER_WINDOW.getType() + windowSize.code() + "@arr", new Object[0]) + .subscribeChannel( + "!" + BinanceSubscriptionType.TICKER_WINDOW.getType() + windowSize.code() + "@arr", + new Object[0]) .map( - (it) -> this.>readTransaction(it, WINDOW_TICKER_TYPE , "ticker")) - .map( transaction -> transaction.getData().stream().map(TickerBinanceWebsocketTransaction::getTicker).collect(Collectors.toList())); + (it) -> + this.>readTransaction( + it, WINDOW_TICKER_TYPE, "ticker")) + .map( + transaction -> + transaction.getData().stream() + .map(TickerBinanceWebsocketTransaction::getTicker) + .collect(Collectors.toList())); } private Observable rawBookTickerStream(Instrument instrument) { @@ -768,7 +788,8 @@ private static JavaType getWindowTickerType() { return getObjectMapper() .getTypeFactory() .constructType( - new TypeReference>>() {}); + new TypeReference< + BinanceWebsocketTransaction>>() {}); } private static JavaType getBookTickerType() { diff --git a/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingAccountServiceIntegration.java b/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingAccountServiceIntegration.java index caee7f5d4a8..c86cb32c84f 100644 --- a/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingAccountServiceIntegration.java +++ b/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingAccountServiceIntegration.java @@ -29,10 +29,11 @@ void spot_balances() { TestObserver testObserver = observable.test(); - List balances = testObserver -// .awaitDone(10, TimeUnit.MINUTES) - .awaitCount(1) - .values(); + List balances = + testObserver + // .awaitDone(10, TimeUnit.MINUTES) + .awaitCount(1) + .values(); testObserver.dispose(); diff --git a/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingMarketDataServiceIntegration.java b/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingMarketDataServiceIntegration.java index e2c13989163..d8c7b0b34c6 100644 --- a/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingMarketDataServiceIntegration.java +++ b/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingMarketDataServiceIntegration.java @@ -22,10 +22,12 @@ void order_book() { TestObserver testObserver = observable.test(); - OrderBook orderBook = testObserver -// .awaitDone(1, TimeUnit.MINUTES) - .awaitCount(1) - .values().get(0); + OrderBook orderBook = + testObserver + // .awaitDone(1, TimeUnit.MINUTES) + .awaitCount(1) + .values() + .get(0); testObserver.dispose(); @@ -45,10 +47,12 @@ void trades() { TestObserver testObserver = observable.test(); - Trade trade = testObserver -// .awaitDone(1, TimeUnit.MINUTES) - .awaitCount(1) - .values().get(0); + Trade trade = + testObserver + // .awaitDone(1, TimeUnit.MINUTES) + .awaitCount(1) + .values() + .get(0); testObserver.dispose(); @@ -63,10 +67,12 @@ void ticker() { TestObserver testObserver = observable.test(); - Ticker ticker = testObserver - .awaitCount(1) -// .awaitDone(1, TimeUnit.MINUTES) - .values().get(0); + Ticker ticker = + testObserver + .awaitCount(1) + // .awaitDone(1, TimeUnit.MINUTES) + .values() + .get(0); testObserver.dispose(); diff --git a/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingTradeServiceIntegration.java b/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingTradeServiceIntegration.java index 68f7a1e6f92..8ea91eee8b1 100644 --- a/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingTradeServiceIntegration.java +++ b/xchange-stream-gateio/src/test/java/info/bitrich/xchangestream/gateio/GateioStreamingTradeServiceIntegration.java @@ -28,10 +28,11 @@ void user_trades_all() { TestObserver testObserver = observable.test(); - List userTrades = testObserver -// .awaitDone(10, TimeUnit.MINUTES) - .awaitCount(1) - .values(); + List userTrades = + testObserver + // .awaitDone(10, TimeUnit.MINUTES) + .awaitCount(1) + .values(); testObserver.dispose(); diff --git a/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingService.java b/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingService.java index 48c8244643a..df3191fb97c 100644 --- a/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingService.java +++ b/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingService.java @@ -252,4 +252,4 @@ public void pingPongDisconnectIfConnected() { pingPongSubscription.dispose(); } } -} \ No newline at end of file +} diff --git a/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java b/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java index 954d4d960a3..f63ff3eada1 100644 --- a/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java +++ b/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java @@ -116,8 +116,8 @@ private void dealWithContinuation(ContinuationWebSocketFrame frame) { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { - if (cause.getMessage() != null && cause.getMessage().toLowerCase() - .contains("connection reset")) { + if (cause.getMessage() != null + && cause.getMessage().toLowerCase().contains("connection reset")) { LOG.warn( "WebSocket client {} encountered exception ({} - {}). Closing", ctx.channel(), @@ -136,4 +136,4 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { } ctx.close(); } -} \ No newline at end of file +}