Skip to content

Commit

Permalink
Merge pull request #4939 from bigscoop/kucoin-minor-improvements
Browse files Browse the repository at this point in the history
[kucoin] Add bid size to tickers
  • Loading branch information
timmolter committed Aug 28, 2024
2 parents 6db82a3 + 310817f commit 3f07487
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
6 changes: 6 additions & 0 deletions xchange-kucoin/example.http-client.private.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": {
"api_key": "replace_me",
"api_secret": "replace_me"
}
}
5 changes: 5 additions & 0 deletions xchange-kucoin/http-client.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"default": {
"api_host": "https://api.kucoin.com"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,7 +105,9 @@ public static List<Ticker> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,6 +77,25 @@ public void testGetTicker() throws Exception {
checkTimestamp(ticker.getTimestamp());
}


@Test
public void valid_tickers() throws IOException {
List<Ticker> 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();
Expand Down
8 changes: 8 additions & 0 deletions xchange-kucoin/src/test/resources/http/market.http
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3f07487

Please sign in to comment.