@icgio/icg-exchanges-wrapper 1.9.18 → 1.9.20

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.
@@ -36,7 +36,7 @@ module.exports = class Account {
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(3) + '%')
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(3) + '%'
56
56
  }
57
57
  }
58
58
  return position
@@ -97,4 +97,18 @@ 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
+ total_in_USD += balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0)
106
+ }
107
+ for (let cur in balances[exchange].total) {
108
+ let percentage = (balances[exchange].total[cur] * _.get(cmc_rates, [cur, 'USD'], 0) / total_in_USD * 100).toPrecision(3) + '%'
109
+ _.set(exchange_distribution, [exchange, cur], percentage)
110
+ }
111
+ }
112
+ return exchange_distribution
113
+ }
100
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-exchanges-wrapper",
3
- "version": "1.9.18",
3
+ "version": "1.9.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
19
19
  "dependencies": {
20
- "@icgio/icg-exchanges": "^1.27.9",
21
- "@icgio/icg-exchanges-data": "^1.6.8",
22
- "@icgio/icg-utils": "^1.7.4",
20
+ "@icgio/icg-exchanges": "^1.27.10",
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",