Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Added ability to query 24hr ticker price change statistics for all sy… #60

Merged
merged 3 commits into from
Feb 6, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,28 @@ public interface BinanceApiAsyncRestClient {
* @param callback the callback that handles the response
*/
void get24HrPriceStatistics(String symbol, BinanceApiCallback<TickerStatistics> callback);

/**
* Get 24 hour price change statistics for all symbols (asynchronous).
*
* @param callback the callback that handles the response
*/
void getAll24HrPriceStatistics(BinanceApiCallback<List<TickerStatistics>> callback);

/**
* Get Latest price for all symbols (asynchronous).
*
* @param callback the callback that handles the response
*/
void getAllPrices(BinanceApiCallback<List<TickerPrice>> callback);

/**
* Get latest price for <code>symbol</code> (asynchronous).
*
* @param symbol ticker symbol (e.g. ETHBTC)
* @param callback the callback that handles the response
*/
void getPrice(String symbol , BinanceApiCallback<TickerPrice> callback);

/**
* Get best price/qty on the order book for all symbols (asynchronous).
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/binance/api/client/BinanceApiRestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<TickerStatistics> getAll24HrPriceStatistics();

/**
* Get Latest price for all symbols.
*/
List<TickerPrice> getAllPrices();

/**
* Get latest price for <code>symbol</code>.
*
* @param symbol ticker symbol (e.g. ETHBTC)
*/
TickerPrice getPrice(String symbol);

/**
* Get best price/qty on the order book for all symbols.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class TickerStatistics {

/**
* Ticker symbol.
*/
private String symbol;

/**
* Price change during the last 24 hours.
*/
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,21 @@ public void getCandlestickBars(String symbol, CandlestickInterval interval, Bina
public void get24HrPriceStatistics(String symbol, BinanceApiCallback<TickerStatistics> callback) {
binanceApiService.get24HrPriceStatistics(symbol).enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void getAll24HrPriceStatistics(BinanceApiCallback<List<TickerStatistics>> callback) {
binanceApiService.getAll24HrPriceStatistics().enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void getAllPrices(BinanceApiCallback<List<TickerPrice>> callback) {
binanceApiService.getLatestPrices().enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void getPrice(String symbol , BinanceApiCallback<TickerPrice> callback) {
binanceApiService.getLatestPrice(symbol).enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void getBookTickers(BinanceApiCallback<List<BookTicker>> callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public TickerStatistics get24HrPriceStatistics(String symbol) {
return executeSync(binanceApiService.get24HrPriceStatistics(symbol));
}

@Override
public List<TickerStatistics> getAll24HrPriceStatistics() {
return executeSync(binanceApiService.getAll24HrPriceStatistics());
}

@Override
public TickerPrice getPrice(String symbol) {
return executeSync(binanceApiService.getLatestPrice(symbol));
}

@Override
public List<TickerPrice> getAllPrices() {
return executeSync(binanceApiService.getLatestPrices());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ Call<List<Candlestick>> getCandlestickBars(@Query("symbol") String symbol, @Quer

@GET("/api/v1/ticker/24hr")
Call<TickerStatistics> get24HrPriceStatistics(@Query("symbol") String symbol);

@GET("/api/v1/ticker/24hr")
Call<List<TickerStatistics>> getAll24HrPriceStatistics();

@GET("/api/v1/ticker/allPrices")
Call<List<TickerPrice>> getLatestPrices();

@GET("/api/v3/ticker/price")
Call<TickerPrice> getLatestPrice(@Query("symbol") String symbol);

@GET("/api/v1/ticker/allBookTickers")
Call<List<BookTicker>> getBookTickers();
Expand Down