@icgio/icg-exchanges-wrapper 1.9.19 → 1.9.21
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 +24 -3
- package/package.json +3 -3
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])
|
|
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]
|
|
55
|
+
position[cur].percentage = (position[cur].amount / this.assets_benchmark[cur] * 100).toPrecision(5) + '%'
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return position
|
|
@@ -97,4 +97,25 @@ module.exports = class Account {
|
|
|
97
97
|
}
|
|
98
98
|
return profit
|
|
99
99
|
}
|
|
100
|
+
get_exchange_distribution (balances, cmc_rates) {
|
|
101
|
+
let exchange_distribution = {}
|
|
102
|
+
for (let exchange in balances) {
|
|
103
|
+
let total_in_USD = 0
|
|
104
|
+
for (let cur in balances[exchange].total) {
|
|
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
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (let cur in balances[exchange].total) {
|
|
112
|
+
if (_.includes(constants.stablecoins, cur)) {
|
|
113
|
+
_.set(exchange_distribution, [exchange, cur], (balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0) / total_in_USD * 100).toPrecision(5) + '%')
|
|
114
|
+
} else {
|
|
115
|
+
_.set(exchange_distribution, [exchange, cur], (balances[exchange].total[cur] * 1 / total_in_USD * 100).toPrecision(5) + '%')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return exchange_distribution
|
|
120
|
+
}
|
|
100
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-exchanges-wrapper",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@icgio/icg-exchanges": "^1.27.10",
|
|
21
|
-
"@icgio/icg-exchanges-data": "^1.6.
|
|
22
|
-
"@icgio/icg-utils": "^1.7.
|
|
21
|
+
"@icgio/icg-exchanges-data": "^1.6.9",
|
|
22
|
+
"@icgio/icg-utils": "^1.7.5",
|
|
23
23
|
"influx": "^5.7.0",
|
|
24
24
|
"lodash": "^4.17.20",
|
|
25
25
|
"needle": "^2.6.0",
|