@icgio/icg-exchanges-wrapper 1.9.23 → 1.9.24

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.
@@ -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
- _.set(exchange_distribution, [exchange, cur], (balances[exchange].total[cur] * 1 / total_in_USD * 100).toPrecision(3) + '%')
114
+ percentage = balances[exchange].total[cur] * 1 / total_in_USD
114
115
  } else {
115
- _.set(exchange_distribution, [exchange, cur], (balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0) / total_in_USD * 100).toPrecision(3) + '%')
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.23",
3
+ "version": "1.9.24",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {