From 21bbb10f9fdeb2b49a29af466650c1dd91d3b3ea Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 15:58:21 +0200 Subject: [PATCH 1/9] adjust Asset class to current api version #1 --- .../api/client/domain/general/Asset.java | 215 ++++++++---------- .../impl/BinanceApiAsyncRestClientImpl.java | 4 +- .../client/impl/BinanceApiRestClientImpl.java | 4 +- .../api/client/impl/BinanceApiService.java | 5 +- .../api/examples/GeneralEndpointsExample.java | 92 ++++---- .../GeneralEndpointsExampleAsync.java | 90 ++++---- 6 files changed, 188 insertions(+), 222 deletions(-) diff --git a/src/main/java/com/binance/api/client/domain/general/Asset.java b/src/main/java/com/binance/api/client/domain/general/Asset.java index 715190f31..d58ba1330 100755 --- a/src/main/java/com/binance/api/client/domain/general/Asset.java +++ b/src/main/java/com/binance/api/client/domain/general/Asset.java @@ -1,123 +1,92 @@ -package com.binance.api.client.domain.general; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.builder.ToStringBuilder; - -/** - * An asset Binance supports. - */ - @JsonIgnoreProperties(ignoreUnknown = true) - public class Asset { - - @JsonProperty("id") - private String id; - - @JsonProperty("assetCode") - private String assetCode; - - @JsonProperty("assetName") - private String assetName; - - @JsonProperty("unit") - private String unit; - - @JsonProperty("transactionFee") - private String transactionFee; - - @JsonProperty("commissionRate") - private String commissionRate; - - @JsonProperty("freeAuditWithdrawAmt") - private String freeAuditWithdrawAmount; - - @JsonProperty("freeUserChargeAmount") - private String freeUserChargeAmount; - - @JsonProperty("minProductWithdraw") - private String minProductWithdraw; - - @JsonProperty("withdrawIntegerMultiple") - private String withdrawIntegerMultiple; - - @JsonProperty("confirmTimes") - private long confirmTimes; - - @JsonProperty("enableWithdraw") - private boolean enableWithdraw; - - @JsonProperty("isLegalMoney") - private boolean isLegalMoney; - - public String getId() { - return id; - } - - public String getAssetCode() { - return assetCode; - } - - public String getAssetName() { - return assetName; - } - - public String getUnit() { - return unit; - } - - public String getTransactionFee() { - return transactionFee; - } - - public String getCommissionRate() { - return commissionRate; - } - - public String getFreeAuditWithdrawAmount() { - return freeAuditWithdrawAmount; - } - - public String getFreeUserChargeAmount() { - return freeUserChargeAmount; - } - - public String minProductWithdraw() { - return minProductWithdraw; - } - - public String getWithdrawIntegerMultiple() { - return withdrawIntegerMultiple; - } - - public long getConfirmTimes() { - return confirmTimes; - } - - public boolean canWithraw() { - return enableWithdraw; - } - - public boolean isLegalMoney() { - return isLegalMoney; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("id", id) - .append("assetCode", assetCode) - .append("assetName", assetName) - .append("unit", unit) - .append("transactionFee", transactionFee) - .append("commissionRate", commissionRate) - .append("freeAuditWithdrawAmount", freeAuditWithdrawAmount) - .append("freeUserChargeAmount", freeUserChargeAmount) - .append("minProductWithdraw", minProductWithdraw) - .append("withdrawIntegerMultiple", withdrawIntegerMultiple) - .append("confirmTimes", confirmTimes) - .append("enableWithdraw", enableWithdraw) - .append("isLegalMoney", isLegalMoney) - .toString(); - } - } +package com.binance.api.client.domain.general; + +import com.binance.api.client.constant.BinanceApiConstants; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * An asset Binance supports. Representing the provided Asset model. See + * Doku + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public class Asset { + + @JsonProperty("assetName") + private String assetName; + + @JsonProperty("assetFullName") + private String assetFullName; + + @JsonProperty("isBorrowable") + private boolean borrowable; + + @JsonProperty("isMortgageable") + private boolean mortgageable; + + @JsonProperty("userMinBorrow") + private double userMinBorrow; + + @JsonProperty("userMinRepay") + private double userMinRepay; + + public String getAssetName() { + return assetName; + } + + public void setAssetName(String assetName) { + this.assetName = assetName; + } + + public String getAssetFullName() { + return assetFullName; + } + + public void setAssetFullName(String assetFullName) { + this.assetFullName = assetFullName; + } + + public boolean isBorrowable() { + return borrowable; + } + + public void setBorrowable(boolean borrowable) { + this.borrowable = borrowable; + } + + public boolean isMortgageable() { + return mortgageable; + } + + public void setMortgageable(boolean mortgageable) { + this.mortgageable = mortgageable; + } + + public double getUserMinBorrow() { + return userMinBorrow; + } + + public void setUserMinBorrow(double userMinBorrow) { + this.userMinBorrow = userMinBorrow; + } + + public double getUserMinRepay() { + return userMinRepay; + } + + public void setUserMinRepay(double userMinRepay) { + this.userMinRepay = userMinRepay; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("assetName", assetName) + .append("assetFullName", assetFullName) + .append("isBorrowable", borrowable) + .append("isMortgageable", mortgageable) + .append("userMinBorrow", userMinBorrow) + .append("userMinRepay", userMinRepay) + .toString(); + } +} 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 e6ea387b9..a1ff47849 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -2,7 +2,6 @@ import com.binance.api.client.BinanceApiAsyncRestClient; import com.binance.api.client.BinanceApiCallback; -import com.binance.api.client.config.BinanceApiConfig; import com.binance.api.client.constant.BinanceApiConstants; import com.binance.api.client.domain.account.Account; import com.binance.api.client.domain.account.DepositAddress; @@ -65,8 +64,7 @@ public void getExchangeInfo(BinanceApiCallback callback) { @Override public void getAllAssets(BinanceApiCallback> callback) { - binanceApiService.getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html") - .enqueue(new BinanceApiCallbackAdapter<>(callback)); + binanceApiService.getAllAssets().enqueue(new BinanceApiCallbackAdapter<>(callback)); } // Market Data endpoints 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 dd647166d..ce7253970 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -1,7 +1,6 @@ package com.binance.api.client.impl; import com.binance.api.client.BinanceApiRestClient; -import com.binance.api.client.config.BinanceApiConfig; import com.binance.api.client.constant.BinanceApiConstants; import com.binance.api.client.domain.account.*; import com.binance.api.client.domain.account.request.*; @@ -46,8 +45,7 @@ public ExchangeInfo getExchangeInfo() { @Override public List getAllAssets() { - return executeSync(binanceApiService - .getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html")); + return executeSync(binanceApiService.getAllAssets()); } // Market Data endpoints 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 35e21de0c..b0f5fbe2a 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -33,8 +33,9 @@ public interface BinanceApiService { @GET("/api/v3/exchangeInfo") Call getExchangeInfo(); - @GET - Call> getAllAssets(@Url String url); + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @GET("/sapi/v1/margin/allAssets") + Call> getAllAssets(); // Market data endpoints diff --git a/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java b/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java index 760d6f26a..57784cba7 100755 --- a/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java +++ b/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java @@ -1,46 +1,46 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiRestClient; -import com.binance.api.client.domain.general.Asset; -import com.binance.api.client.domain.general.ExchangeInfo; -import com.binance.api.client.domain.general.FilterType; -import com.binance.api.client.domain.general.SymbolFilter; -import com.binance.api.client.domain.general.SymbolInfo; - -import java.util.List; - -/** - * Examples on how to use the general endpoints. - */ -public class GeneralEndpointsExample { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(); - BinanceApiRestClient client = factory.newRestClient(); - - // Test connectivity - client.ping(); - - // Check server time - long serverTime = client.getServerTime(); - System.out.println(serverTime); - - // Exchange info - ExchangeInfo exchangeInfo = client.getExchangeInfo(); - System.out.println(exchangeInfo.getTimezone()); - System.out.println(exchangeInfo.getSymbols()); - - // Obtain symbol information - SymbolInfo symbolInfo = exchangeInfo.getSymbolInfo("ETHBTC"); - System.out.println(symbolInfo.getStatus()); - - SymbolFilter priceFilter = symbolInfo.getSymbolFilter(FilterType.PRICE_FILTER); - System.out.println(priceFilter.getMinPrice()); - System.out.println(priceFilter.getTickSize()); - - // Obtain asset information - List allAssets = client.getAllAssets(); - System.out.println(allAssets.stream().filter(asset -> asset.getAssetCode().equals("BNB")).findFirst().get()); - } -} +package com.binance.api.examples; + +import com.binance.api.client.BinanceApiClientFactory; +import com.binance.api.client.BinanceApiRestClient; +import com.binance.api.client.domain.general.Asset; +import com.binance.api.client.domain.general.ExchangeInfo; +import com.binance.api.client.domain.general.FilterType; +import com.binance.api.client.domain.general.SymbolFilter; +import com.binance.api.client.domain.general.SymbolInfo; + +import java.util.List; + +/** + * Examples on how to use the general endpoints. + */ +public class GeneralEndpointsExample { + + public static void main(String[] args) { + BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(); + BinanceApiRestClient client = factory.newRestClient(); + + // Test connectivity + client.ping(); + + // Check server time + long serverTime = client.getServerTime(); + System.out.println(serverTime); + + // Exchange info + ExchangeInfo exchangeInfo = client.getExchangeInfo(); + System.out.println(exchangeInfo.getTimezone()); + System.out.println(exchangeInfo.getSymbols()); + + // Obtain symbol information + SymbolInfo symbolInfo = exchangeInfo.getSymbolInfo("ETHBTC"); + System.out.println(symbolInfo.getStatus()); + + SymbolFilter priceFilter = symbolInfo.getSymbolFilter(FilterType.PRICE_FILTER); + System.out.println(priceFilter.getMinPrice()); + System.out.println(priceFilter.getTickSize()); + + // Obtain asset information + List allAssets = client.getAllAssets(); + System.out.println(allAssets.stream().filter(asset -> asset.getAssetName().equals("BNB")).findFirst().get()); + } +} diff --git a/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java b/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java index 96739a5c2..35b8cb882 100755 --- a/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java +++ b/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java @@ -1,45 +1,45 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiAsyncRestClient; -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.domain.general.Asset; -import com.binance.api.client.domain.general.FilterType; -import com.binance.api.client.domain.general.SymbolFilter; -import com.binance.api.client.domain.general.SymbolInfo; - -import java.util.List; - -/** - * Examples on how to use the general endpoints. - */ -public class GeneralEndpointsExampleAsync { - - public static void main(String[] args) throws InterruptedException { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(); - BinanceApiAsyncRestClient client = factory.newAsyncRestClient(); - - // Test connectivity - client.ping(response -> System.out.println("Ping succeeded.")); - - // Check server time - client.getServerTime(response -> System.out.println(response.getServerTime())); - - // Exchange info - client.getExchangeInfo(exchangeInfo -> { - System.out.println(exchangeInfo.getTimezone()); - System.out.println(exchangeInfo.getSymbols()); - - // Obtain symbol information - SymbolInfo symbolInfo = exchangeInfo.getSymbolInfo("ETHBTC"); - System.out.println(symbolInfo.getStatus()); - - SymbolFilter priceFilter = symbolInfo.getSymbolFilter(FilterType.PRICE_FILTER); - System.out.println(priceFilter.getMinPrice()); - System.out.println(priceFilter.getTickSize()); - }); - - // Obtain asset information - client.getAllAssets(allAssets -> - System.out.println(allAssets.stream().filter(asset -> asset.getAssetCode().equals("BNB")).findFirst().get())); - } -} +package com.binance.api.examples; + +import com.binance.api.client.BinanceApiAsyncRestClient; +import com.binance.api.client.BinanceApiClientFactory; +import com.binance.api.client.domain.general.Asset; +import com.binance.api.client.domain.general.FilterType; +import com.binance.api.client.domain.general.SymbolFilter; +import com.binance.api.client.domain.general.SymbolInfo; + +import java.util.List; + +/** + * Examples on how to use the general endpoints. + */ +public class GeneralEndpointsExampleAsync { + + public static void main(String[] args) throws InterruptedException { + BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(); + BinanceApiAsyncRestClient client = factory.newAsyncRestClient(); + + // Test connectivity + client.ping(response -> System.out.println("Ping succeeded.")); + + // Check server time + client.getServerTime(response -> System.out.println(response.getServerTime())); + + // Exchange info + client.getExchangeInfo(exchangeInfo -> { + System.out.println(exchangeInfo.getTimezone()); + System.out.println(exchangeInfo.getSymbols()); + + // Obtain symbol information + SymbolInfo symbolInfo = exchangeInfo.getSymbolInfo("ETHBTC"); + System.out.println(symbolInfo.getStatus()); + + SymbolFilter priceFilter = symbolInfo.getSymbolFilter(FilterType.PRICE_FILTER); + System.out.println(priceFilter.getMinPrice()); + System.out.println(priceFilter.getTickSize()); + }); + + // Obtain asset information + client.getAllAssets(allAssets -> + System.out.println(allAssets.stream().filter(asset -> asset.getAssetName().equals("BNB")).findFirst().get())); + } +} From e6c5664f1642511aa6bae2587576d4fb9e0e339d Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 16:12:16 +0200 Subject: [PATCH 2/9] create new model for TradeFee #2 --- .../api/client/BinanceApiAsyncRestClient.java | 6 ++ .../api/client/BinanceApiRestClient.java | 6 ++ .../api/client/domain/general/TradeFee.java | 57 +++++++++++++++++++ .../client/impl/BinanceApiRestClientImpl.java | 6 ++ .../api/client/impl/BinanceApiService.java | 5 ++ 5 files changed, 80 insertions(+) create mode 100644 src/main/java/com/binance/api/client/domain/general/TradeFee.java diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index d0e3b1c01..3ad22156d 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -19,6 +19,7 @@ import com.binance.api.client.domain.general.Asset; import com.binance.api.client.domain.general.ExchangeInfo; import com.binance.api.client.domain.general.ServerTime; +import com.binance.api.client.domain.general.TradeFee; import com.binance.api.client.domain.market.AggTrade; import com.binance.api.client.domain.market.BookTicker; import com.binance.api.client.domain.market.Candlestick; @@ -56,6 +57,11 @@ public interface BinanceApiAsyncRestClient { */ void getAllAssets(BinanceApiCallback> callback); + /** + * @return All trade fees for each asset. + */ + void getAllTradeFees(BinanceApiCallback> callback); + // Market Data endpoints /** diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index bfc4797c4..6fb75cd9c 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -7,6 +7,7 @@ import com.binance.api.client.domain.account.request.OrderRequest; import com.binance.api.client.domain.account.request.OrderStatusRequest; import com.binance.api.client.domain.general.ExchangeInfo; +import com.binance.api.client.domain.general.TradeFee; import com.binance.api.client.domain.general.Asset; import com.binance.api.client.domain.market.AggTrade; import com.binance.api.client.domain.market.BookTicker; @@ -47,6 +48,11 @@ public interface BinanceApiRestClient { */ List getAllAssets(); + /** + * @return All trade fees for each asset. + */ + List getAllTradeFees(); + // Market Data endpoints /** diff --git a/src/main/java/com/binance/api/client/domain/general/TradeFee.java b/src/main/java/com/binance/api/client/domain/general/TradeFee.java new file mode 100644 index 000000000..79383600d --- /dev/null +++ b/src/main/java/com/binance/api/client/domain/general/TradeFee.java @@ -0,0 +1,57 @@ +package com.binance.api.client.domain.general; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.binance.api.client.constant.BinanceApiConstants; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An TradeFee Binance supports. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TradeFee { + + @JsonProperty("symbol") + private String symbol; + + @JsonProperty("maker") + private double maker; + + @JsonProperty("taker") + private double taker; + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public double getMaker() { + return maker; + } + + public void setMaker(double maker) { + this.maker = maker; + } + + public double getTaker() { + return taker; + } + + public void setTaker(double taker) { + this.taker = taker; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("id", symbol) + .append("symbol", symbol) + .append("maker", maker) + .append("taker", taker) + .toString(); + } +} 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 ce7253970..1be2a5127 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -6,6 +6,7 @@ import com.binance.api.client.domain.account.request.*; import com.binance.api.client.domain.general.Asset; import com.binance.api.client.domain.general.ExchangeInfo; +import com.binance.api.client.domain.general.TradeFee; import com.binance.api.client.domain.market.*; import retrofit2.Call; @@ -48,6 +49,11 @@ public List getAllAssets() { return executeSync(binanceApiService.getAllAssets()); } + @Override + public List getAllTradeFees() { + return executeSync(binanceApiService.getAllTradeFees()); + } + // Market Data endpoints @Override 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 b0f5fbe2a..3f805643b 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -11,6 +11,7 @@ import com.binance.api.client.domain.general.Asset; import com.binance.api.client.domain.general.ExchangeInfo; import com.binance.api.client.domain.general.ServerTime; +import com.binance.api.client.domain.general.TradeFee; import com.binance.api.client.domain.market.*; import retrofit2.Call; import retrofit2.http.*; @@ -37,6 +38,10 @@ public interface BinanceApiService { @GET("/sapi/v1/margin/allAssets") Call> getAllAssets(); + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @GET("/sapi/v1/asset/tradeFee") + Call> getAllTradeFees(); + // Market data endpoints @GET("/api/v1/depth") From c38d878c71e540ef86e8688a6f982ce5a2b9b23f Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 16:14:38 +0200 Subject: [PATCH 3/9] add missing implementation for TradeFees in AsyncRestClient #2 --- .../api/client/impl/BinanceApiAsyncRestClientImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 a1ff47849..1d4256c18 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -22,6 +22,7 @@ import com.binance.api.client.domain.general.Asset; import com.binance.api.client.domain.general.ExchangeInfo; import com.binance.api.client.domain.general.ServerTime; +import com.binance.api.client.domain.general.TradeFee; import com.binance.api.client.domain.market.AggTrade; import com.binance.api.client.domain.market.BookTicker; import com.binance.api.client.domain.market.Candlestick; @@ -67,6 +68,11 @@ public void getAllAssets(BinanceApiCallback> callback) { binanceApiService.getAllAssets().enqueue(new BinanceApiCallbackAdapter<>(callback)); } + @Override + public void getAllTradeFees(BinanceApiCallback> callback) { + binanceApiService.getAllTradeFees().enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + // Market Data endpoints @Override From 7fdb566381f8b05dec3bee75bc7c43b1a2f8a0d9 Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 16:40:04 +0200 Subject: [PATCH 4/9] add missing api call parameter #2 --- .../com/binance/api/client/BinanceApiAsyncRestClient.java | 2 +- .../java/com/binance/api/client/BinanceApiRestClient.java | 8 ++++---- .../api/client/impl/BinanceApiAsyncRestClientImpl.java | 4 ++-- .../binance/api/client/impl/BinanceApiRestClientImpl.java | 4 ++-- .../com/binance/api/client/impl/BinanceApiService.java | 3 ++- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index 3ad22156d..812ed75aa 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -60,7 +60,7 @@ public interface BinanceApiAsyncRestClient { /** * @return All trade fees for each asset. */ - void getAllTradeFees(BinanceApiCallback> callback); + void getAllTradeFees(long timestamp, String symbol, Long recvWindow, BinanceApiCallback> callback); // Market Data endpoints diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index 6fb75cd9c..7f5f0e7df 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -48,10 +48,10 @@ public interface BinanceApiRestClient { */ List getAllAssets(); - /** - * @return All trade fees for each asset. - */ - List getAllTradeFees(); + /** + * @return All trade fees for each asset. + */ + List getAllTradeFees(long timestamp, String symbol, Long recvWindow); // Market Data endpoints 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 1d4256c18..6c9c83c17 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -69,8 +69,8 @@ public void getAllAssets(BinanceApiCallback> callback) { } @Override - public void getAllTradeFees(BinanceApiCallback> callback) { - binanceApiService.getAllTradeFees().enqueue(new BinanceApiCallbackAdapter<>(callback)); + public void getAllTradeFees(long timestamp, String symbol, Long recvWindow, BinanceApiCallback> callback) { + binanceApiService.getAllTradeFees(timestamp, symbol, recvWindow).enqueue(new BinanceApiCallbackAdapter<>(callback)); } // Market Data endpoints 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 1be2a5127..8891293d2 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -50,8 +50,8 @@ public List getAllAssets() { } @Override - public List getAllTradeFees() { - return executeSync(binanceApiService.getAllTradeFees()); + public List getAllTradeFees(long timestamp, String symbol, Long recvWindow) { + return executeSync(binanceApiService.getAllTradeFees(timestamp, symbol, recvWindow)); } // Market Data endpoints 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 3f805643b..5f0068194 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -40,7 +40,8 @@ public interface BinanceApiService { @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) @GET("/sapi/v1/asset/tradeFee") - Call> getAllTradeFees(); + Call> getAllTradeFees(@Query("timestamp") long timestamp, @Query("symbol") String symbol, + @Query("recvWindow") Long recvWindow); // Market data endpoints From ed6fb97723325faf3d38fb6266071fe53ab48d3d Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 16:40:20 +0200 Subject: [PATCH 5/9] adjust endpoint security #2 --- .../java/com/binance/api/client/impl/BinanceApiService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5f0068194..9cca7eca3 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -38,7 +38,7 @@ public interface BinanceApiService { @GET("/sapi/v1/margin/allAssets") Call> getAllAssets(); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) @GET("/sapi/v1/asset/tradeFee") Call> getAllTradeFees(@Query("timestamp") long timestamp, @Query("symbol") String symbol, @Query("recvWindow") Long recvWindow); From 56b80914b05aab96b9a525e0b47c9993c0245046 Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 16:41:05 +0200 Subject: [PATCH 6/9] adjust test suite #2 --- .../com/binance/api/examples/GeneralEndpointsExample.java | 4 ++++ .../binance/api/examples/GeneralEndpointsExampleAsync.java | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java b/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java index 57784cba7..b8b252ba0 100755 --- a/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java +++ b/src/test/java/com/binance/api/examples/GeneralEndpointsExample.java @@ -7,6 +7,7 @@ import com.binance.api.client.domain.general.FilterType; import com.binance.api.client.domain.general.SymbolFilter; import com.binance.api.client.domain.general.SymbolInfo; +import com.binance.api.client.domain.general.TradeFee; import java.util.List; @@ -42,5 +43,8 @@ public static void main(String[] args) { // Obtain asset information List allAssets = client.getAllAssets(); System.out.println(allAssets.stream().filter(asset -> asset.getAssetName().equals("BNB")).findFirst().get()); + + List allTradeFees = client.getAllTradeFees(System.currentTimeMillis(), null, null); + System.out.println(allTradeFees.stream().filter(fee -> fee.getSymbol().equals("ETHBTC")).findFirst().get()); } } diff --git a/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java b/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java index 35b8cb882..8e7886691 100755 --- a/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java +++ b/src/test/java/com/binance/api/examples/GeneralEndpointsExampleAsync.java @@ -41,5 +41,10 @@ public static void main(String[] args) throws InterruptedException { // Obtain asset information client.getAllAssets(allAssets -> System.out.println(allAssets.stream().filter(asset -> asset.getAssetName().equals("BNB")).findFirst().get())); + + // Obtain tradeFee + client.getAllTradeFees(System.currentTimeMillis(), "ETHBTC", null, allTradeFees -> { + System.out.println(allTradeFees); + }); } } From 4d6b748ef2bacd8111ce24439b6a32cf9d097fd3 Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Mon, 5 Apr 2021 16:42:36 +0200 Subject: [PATCH 7/9] adjust mvn version number to meet the current pom version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf74d5d02..ba11f5a74 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ binance-java-api is a lightweight Java library for interacting with the [Binance com.binance.api binance-api-client - 1.0.0 + 1.0.1 ``` From 47073093c7313179b76abd2216944253c77aee7b Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Sun, 18 Apr 2021 20:14:17 +0200 Subject: [PATCH 8/9] add missing mvn-compile-plugin version --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 863f5c234..ecb6a80f7 100755 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 1.8 1.8 From 6a85d5590bd6437e328e1ba39942b8161e6442f4 Mon Sep 17 00:00:00 2001 From: Marcel Hodan Date: Sun, 18 Apr 2021 20:30:32 +0200 Subject: [PATCH 9/9] adjust JsonProperties to current BinanceApi --- .../java/com/binance/api/client/domain/general/TradeFee.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/binance/api/client/domain/general/TradeFee.java b/src/main/java/com/binance/api/client/domain/general/TradeFee.java index 79383600d..3179566ed 100644 --- a/src/main/java/com/binance/api/client/domain/general/TradeFee.java +++ b/src/main/java/com/binance/api/client/domain/general/TradeFee.java @@ -15,10 +15,10 @@ public class TradeFee { @JsonProperty("symbol") private String symbol; - @JsonProperty("maker") + @JsonProperty("makerCommission") private double maker; - @JsonProperty("taker") + @JsonProperty("takerCommission") private double taker; public String getSymbol() {