Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kucoin] Add bid size to tickers #4939

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading