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

Commit 64d121b

Browse files
committed
add comments
1 parent e97c006 commit 64d121b

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/main/java/com/binance/api/client/constant/Util.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
import java.util.Collections;
66
import java.util.List;
77

8+
/**
9+
* Utility class
10+
*/
811
public final class Util {
912

13+
/**
14+
* List of fiat currencies.
15+
*/
1016
public static final List<String> FIAT_CURRENCY = Collections.unmodifiableList(Arrays.asList("USDT", "BUSD", "PAX", "TUSD", "USDC", "NGN", "RUB", "USDS, TRY"));
1117

1218
public static final String BTC_TICKER = "BTC";
@@ -15,6 +21,9 @@ private Util() {
1521
throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
1622
}
1723

24+
/**
25+
* Check if the ticker is fiat currency.
26+
*/
1827
public static boolean isFiatCurrency(String symbol) {
1928
for (String fiat : FIAT_CURRENCY) {
2029
if (symbol.equals(fiat)) return true;

src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import com.binance.api.client.domain.account.Account;
77
import com.binance.api.client.domain.account.AssetBalance;
88

9-
9+
/**
10+
* Example how to get total of balances on your account
11+
*/
1012
public class TotalAccountBalanceExample {
1113

1214

@@ -20,10 +22,9 @@ public static void main(String[] args) {
2022
// Get total account balance in BTC (spot only)
2123
TotalAccountBalanceExample accountBalance = new TotalAccountBalanceExample();
2224
double totalBalanceInBTC = accountBalance.getTotalAccountBalance(client,account);
25+
System.out.println(totalBalanceInBTC);
2326
// Get total account balance in USDT (spot only)
2427
double totalBalanceInUSDT = totalBalanceInBTC * Double.parseDouble(client.getPrice("BTCUSDT").getPrice());
25-
26-
System.out.println(totalBalanceInBTC);
2728
System.out.println(totalBalanceInUSDT);
2829

2930

@@ -38,10 +39,10 @@ public double getTotalAccountBalance(BinanceApiRestClient client, Account accoun
3839
double free = Double.parseDouble(balance.getFree());
3940
double locked = Double.parseDouble(balance.getLocked());
4041
String ticker = balance.getAsset() + Util.BTC_TICKER;
41-
String tickerRev = Util.BTC_TICKER + balance.getAsset();
42+
String tickerReverse = Util.BTC_TICKER + balance.getAsset();
4243
if (free + locked != 0) {
4344
if (Util.isFiatCurrency(balance.getAsset())) {
44-
double price = Double.parseDouble(client.getPrice(tickerRev).getPrice());
45+
double price = Double.parseDouble(client.getPrice(tickerReverse).getPrice());
4546
double amount = (free + locked) / price;
4647
totalBalance += amount;
4748
} else {

0 commit comments

Comments
 (0)