@icgio/icg-exchanges-wrapper 1.9.20 → 1.9.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/middleware/account.js +13 -6
- package/package.json +1 -1
package/middleware/account.js
CHANGED
|
@@ -31,12 +31,12 @@ module.exports = class Account {
|
|
|
31
31
|
let exchange_position = {}
|
|
32
32
|
for (let exchange in exchange_assets_benchmark) {
|
|
33
33
|
for (let cur in exchange_assets_benchmark[exchange]) {
|
|
34
|
-
if (!_.get(balances, [exchange, 'total']))
|
|
34
|
+
if (!_.get(balances, [exchange, 'total']))
|
|
35
35
|
console.error('get_exchange_position error: ', exchange, balances[exchange])
|
|
36
36
|
if (_.get(balances, [exchange, 'total', cur])) {
|
|
37
37
|
let diff = balances[exchange].total[cur] - exchange_assets_benchmark[exchange][cur]
|
|
38
38
|
_.set(exchange_position, [exchange, cur, 'amount'], diff)
|
|
39
|
-
_.set(exchange_position, [exchange, cur, 'percentage'], (diff / exchange_assets_benchmark[exchange][cur] * 100).toPrecision(
|
|
39
|
+
_.set(exchange_position, [exchange, cur, 'percentage'], (diff / exchange_assets_benchmark[exchange][cur] * 100).toPrecision(5) + '%')
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -52,7 +52,7 @@ module.exports = class Account {
|
|
|
52
52
|
_.set(position, [cur, 'percentage'], 0)
|
|
53
53
|
}
|
|
54
54
|
position[cur].amount += exchange_position[exchange][cur].amount
|
|
55
|
-
position[cur].percentage = (position[cur].amount / this.assets_benchmark[cur] * 100).toPrecision(
|
|
55
|
+
position[cur].percentage = (position[cur].amount / this.assets_benchmark[cur] * 100).toPrecision(5) + '%'
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return position
|
|
@@ -102,11 +102,18 @@ module.exports = class Account {
|
|
|
102
102
|
for (let exchange in balances) {
|
|
103
103
|
let total_in_USD = 0
|
|
104
104
|
for (let cur in balances[exchange].total) {
|
|
105
|
-
|
|
105
|
+
if (_.includes(constants.stablecoins, cur)) {
|
|
106
|
+
total_in_USD += balances[exchange].total[cur] * 1
|
|
107
|
+
} else {
|
|
108
|
+
total_in_USD += balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0)
|
|
109
|
+
}
|
|
106
110
|
}
|
|
107
111
|
for (let cur in balances[exchange].total) {
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
if (_.includes(constants.stablecoins, cur)) {
|
|
113
|
+
_.set(exchange_distribution, [exchange, cur], (balances[exchange].total[cur] * 1 / total_in_USD * 100).toPrecision(5) + '%')
|
|
114
|
+
} else {
|
|
115
|
+
_.set(exchange_distribution, [exchange, cur], (balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0) / total_in_USD * 100).toPrecision(5) + '%')
|
|
116
|
+
}
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
return exchange_distribution
|