@icgio/icg-exchanges-wrapper 1.9.23 → 1.9.25
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 +35 -4
- package/package.json +2 -2
package/middleware/account.js
CHANGED
|
@@ -76,9 +76,9 @@ module.exports = class Account {
|
|
|
76
76
|
profit.USD += position / USDCNY
|
|
77
77
|
} else {
|
|
78
78
|
if (!cmc_rates[cur]) {
|
|
79
|
-
console.
|
|
79
|
+
console.log('get_exchange_profit rates_cmc %s does not exist', cur)
|
|
80
80
|
} else if (cmc_rates[cur].update_time < new Date().getTime() - 4 * 60 * 60 * 1000) { // some currencies like USDT are updating slow
|
|
81
|
-
console.
|
|
81
|
+
console.log('get_exchange_profit rates_cmc %s expired', cur)
|
|
82
82
|
}
|
|
83
83
|
profit.USD += position * _.get(cmc_rates, [cur, 'USD'], 0)
|
|
84
84
|
}
|
|
@@ -109,13 +109,44 @@ module.exports = class Account {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
for (let cur in balances[exchange].total) {
|
|
112
|
+
let percentage = 0
|
|
112
113
|
if (_.includes(constants.stablecoins, cur)) {
|
|
113
|
-
|
|
114
|
+
percentage = balances[exchange].total[cur] * 1 / total_in_USD
|
|
114
115
|
} else {
|
|
115
|
-
|
|
116
|
+
percentage = balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0) / total_in_USD
|
|
117
|
+
}
|
|
118
|
+
if (percentage > 0.0001) {
|
|
119
|
+
_.set(exchange_distribution, [exchange, cur], (percentage * 100).toPrecision(3) + '%')
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
return exchange_distribution
|
|
120
124
|
}
|
|
125
|
+
get_total_distribution (balances, cmc_rates) {
|
|
126
|
+
let total_distribution = {}
|
|
127
|
+
let total_in_USD = 0
|
|
128
|
+
for (let exchange in balances) {
|
|
129
|
+
for (let cur in balances[exchange].total) {
|
|
130
|
+
if (_.includes(constants.stablecoins, cur)) {
|
|
131
|
+
total_in_USD += balances[exchange].total[cur] * 1
|
|
132
|
+
} else {
|
|
133
|
+
total_in_USD += balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (let exchange in balances) {
|
|
138
|
+
for (let cur in balances[exchange].total) {
|
|
139
|
+
let percentage = 0
|
|
140
|
+
if (_.includes(constants.stablecoins, cur)) {
|
|
141
|
+
percentage = balances[exchange].total[cur] * 1 / total_in_USD
|
|
142
|
+
} else {
|
|
143
|
+
percentage = balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0) / total_in_USD
|
|
144
|
+
}
|
|
145
|
+
if (percentage > 0.0001) {
|
|
146
|
+
_.set(total_distribution, [cur, exchange], (percentage * 100).toPrecision(3) + '%')
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return total_distribution
|
|
151
|
+
}
|
|
121
152
|
}
|
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.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@icgio/icg-exchanges": "^1.27.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.27.11",
|
|
21
21
|
"@icgio/icg-exchanges-data": "^1.6.9",
|
|
22
22
|
"@icgio/icg-utils": "^1.7.5",
|
|
23
23
|
"influx": "^5.7.0",
|