diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index f4bbbc700..0b1fd3920 100644 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -108,6 +108,13 @@ public interface BinanceApiAsyncRestClient { * @param callback the callback that handles the response */ void get24HrPriceStatistics(String symbol, BinanceApiCallback callback); + + /** + * Get 24 hour price change statistics for all symbols (asynchronous). + * + * @param callback the callback that handles the response + */ + void getAll24HrPriceStatistics(BinanceApiCallback> callback); /** * Get Latest price for all symbols (asynchronous). @@ -115,6 +122,14 @@ public interface BinanceApiAsyncRestClient { * @param callback the callback that handles the response */ void getAllPrices(BinanceApiCallback> callback); + + /** + * Get latest price for symbol (asynchronous). + * + * @param symbol ticker symbol (e.g. ETHBTC) + * @param callback the callback that handles the response + */ + void getPrice(String symbol , BinanceApiCallback callback); /** * Get best price/qty on the order book for all symbols (asynchronous). diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index d81b05d25..13de14178 100644 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -105,11 +105,23 @@ public interface BinanceApiRestClient { * @param symbol ticker symbol (e.g. ETHBTC) */ TickerStatistics get24HrPriceStatistics(String symbol); + + /** + * Get 24 hour price change statistics for all symbols. + */ + List getAll24HrPriceStatistics(); /** * Get Latest price for all symbols. */ List getAllPrices(); + + /** + * Get latest price for symbol. + * + * @param symbol ticker symbol (e.g. ETHBTC) + */ + TickerPrice getPrice(String symbol); /** * Get best price/qty on the order book for all symbols. diff --git a/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java b/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java index 204ee2147..aab7d57b1 100644 --- a/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java +++ b/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java @@ -10,6 +10,11 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class TickerStatistics { + /** + * Ticker symbol. + */ + private String symbol; + /** * Price change during the last 24 hours. */ @@ -217,10 +222,19 @@ public long getCount() { public void setCount(long count) { this.count = count; } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } - @Override +@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("symbol", symbol) .append("priceChange", priceChange) .append("priceChangePercent", priceChangePercent) .append("weightedAvgPrice", weightedAvgPrice) diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java index ffdec9ea7..370265750 100644 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -89,11 +89,21 @@ public void getCandlestickBars(String symbol, CandlestickInterval interval, Bina public void get24HrPriceStatistics(String symbol, BinanceApiCallback callback) { binanceApiService.get24HrPriceStatistics(symbol).enqueue(new BinanceApiCallbackAdapter<>(callback)); } + + @Override + public void getAll24HrPriceStatistics(BinanceApiCallback> callback) { + binanceApiService.getAll24HrPriceStatistics().enqueue(new BinanceApiCallbackAdapter<>(callback)); + } @Override public void getAllPrices(BinanceApiCallback> callback) { binanceApiService.getLatestPrices().enqueue(new BinanceApiCallbackAdapter<>(callback)); } + + @Override + public void getPrice(String symbol , BinanceApiCallback callback) { + binanceApiService.getLatestPrice(symbol).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } @Override public void getBookTickers(BinanceApiCallback> callback) { diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index 0390ac7ab..fc5b6d599 100644 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -88,6 +88,16 @@ public TickerStatistics get24HrPriceStatistics(String symbol) { return executeSync(binanceApiService.get24HrPriceStatistics(symbol)); } + @Override + public List getAll24HrPriceStatistics() { + return executeSync(binanceApiService.getAll24HrPriceStatistics()); + } + + @Override + public TickerPrice getPrice(String symbol) { + return executeSync(binanceApiService.getLatestPrice(symbol)); + } + @Override public List getAllPrices() { return executeSync(binanceApiService.getLatestPrices()); diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index 17c089f92..6be99c867 100644 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -61,9 +61,15 @@ Call> getCandlestickBars(@Query("symbol") String symbol, @Quer @GET("/api/v1/ticker/24hr") Call get24HrPriceStatistics(@Query("symbol") String symbol); + + @GET("/api/v1/ticker/24hr") + Call> getAll24HrPriceStatistics(); @GET("/api/v1/ticker/allPrices") Call> getLatestPrices(); + + @GET("/api/v3/ticker/price") + Call getLatestPrice(@Query("symbol") String symbol); @GET("/api/v1/ticker/allBookTickers") Call> getBookTickers();