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

implement some changes from latest binance changelog #343

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ binance-java-api is a lightweight Java library for interacting with the [Binance
<dependency>
<groupId>com.binance.api</groupId>
<artifactId>binance-api-client</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
```

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,6 +57,11 @@ public interface BinanceApiAsyncRestClient {
*/
void getAllAssets(BinanceApiCallback<List<Asset>> callback);

/**
* @return All trade fees for each asset.
*/
void getAllTradeFees(long timestamp, String symbol, Long recvWindow, BinanceApiCallback<List<TradeFee>> callback);

// Market Data endpoints

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,6 +48,11 @@ public interface BinanceApiRestClient {
*/
List<Asset> getAllAssets();

/**
* @return All trade fees for each asset.
*/
List<TradeFee> getAllTradeFees(long timestamp, String symbol, Long recvWindow);

// Market Data endpoints

/**
Expand Down
215 changes: 92 additions & 123 deletions src/main/java/com/binance/api/client/domain/general/Asset.java
Original file line number Diff line number Diff line change
@@ -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. <a href=
* "https://binance-docs.github.io/apidocs/spot/en/#get-all-margin-assets-market_data">See
* Doku</a>
*/
@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();
}
}
57 changes: 57 additions & 0 deletions src/main/java/com/binance/api/client/domain/general/TradeFee.java
Original file line number Diff line number Diff line change
@@ -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("makerCommission")
private double maker;

@JsonProperty("takerCommission")
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,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;
Expand Down Expand Up @@ -65,8 +65,12 @@ public void getExchangeInfo(BinanceApiCallback<ExchangeInfo> callback) {

@Override
public void getAllAssets(BinanceApiCallback<List<Asset>> callback) {
binanceApiService.getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html")
.enqueue(new BinanceApiCallbackAdapter<>(callback));
binanceApiService.getAllAssets().enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void getAllTradeFees(long timestamp, String symbol, Long recvWindow, BinanceApiCallback<List<TradeFee>> callback) {
binanceApiService.getAllTradeFees(timestamp, symbol, recvWindow).enqueue(new BinanceApiCallbackAdapter<>(callback));
}

// Market Data endpoints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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.*;
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;

Expand Down Expand Up @@ -46,8 +46,12 @@ public ExchangeInfo getExchangeInfo() {

@Override
public List<Asset> getAllAssets() {
return executeSync(binanceApiService
.getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html"));
return executeSync(binanceApiService.getAllAssets());
}

@Override
public List<TradeFee> getAllTradeFees(long timestamp, String symbol, Long recvWindow) {
return executeSync(binanceApiService.getAllTradeFees(timestamp, symbol, recvWindow));
}

// Market Data endpoints
Expand Down
Loading