MCPcopy Index your code
hub / github.com/ccxt/ccxt / Balances

Method Balances

java/lib/src/main/java/io/github/ccxt/types/Balances.java:15–53  ·  view source on GitHub ↗
(Object raw)

Source from the content-addressed store, hash-verified

13 public Map<String, Object> info;
14
15 @SuppressWarnings("unchecked")
16 public Balances(Object raw) {
17 Map<String, Object> data = TypeHelper.toMap(raw);
18 this.info = TypeHelper.getInfo(data);
19 this.timestamp = TypeHelper.safeInteger(data, "timestamp");
20 this.datetime = TypeHelper.safeString(data, "datetime");
21 this.balances = new LinkedHashMap<>();
22 this.free = new LinkedHashMap<>();
23 this.used = new LinkedHashMap<>();
24 this.total = new LinkedHashMap<>();
25 Object freeRaw = TypeHelper.safeValue(data, "free");
26 if (freeRaw instanceof Map<?, ?> freeMap) {
27 for (Map.Entry<String, Object> entry : ((Map<String, Object>) freeMap).entrySet()) {
28 Double val = entry.getValue() instanceof Number n ? n.doubleValue() : null;
29 this.free.put(entry.getKey(), val);
30 }
31 }
32 Object usedRaw = TypeHelper.safeValue(data, "used");
33 if (usedRaw instanceof Map<?, ?> usedMap) {
34 for (Map.Entry<String, Object> entry : ((Map<String, Object>) usedMap).entrySet()) {
35 Double val = entry.getValue() instanceof Number n ? n.doubleValue() : null;
36 this.used.put(entry.getKey(), val);
37 }
38 }
39 Object totalRaw = TypeHelper.safeValue(data, "total");
40 if (totalRaw instanceof Map<?, ?> totalMap) {
41 for (Map.Entry<String, Object> entry : ((Map<String, Object>) totalMap).entrySet()) {
42 Double val = entry.getValue() instanceof Number n ? n.doubleValue() : null;
43 this.total.put(entry.getKey(), val);
44 }
45 }
46 for (Map.Entry<String, Object> entry : data.entrySet()) {
47 String key = entry.getKey();
48 if (!"info".equals(key) && !"free".equals(key) && !"used".equals(key) && !"total".equals(key)
49 && !"timestamp".equals(key) && !"datetime".equals(key) && entry.getValue() instanceof Map) {
50 this.balances.put(key, new Balance(entry.getValue()));
51 }
52 }
53 }
54
55 public Balance get(String currency) {
56 return balances.get(currency);

Callers

nothing calls this directly

Calls 7

toMapMethod · 0.95
getInfoMethod · 0.95
safeIntegerMethod · 0.95
safeStringMethod · 0.95
safeValueMethod · 0.95
getValueMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected