@icgio/icg-utils 1.9.36 → 1.9.38

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.
Files changed (2) hide show
  1. package/lib/utils.js +24 -4
  2. package/package.json +2 -4
package/lib/utils.js CHANGED
@@ -276,7 +276,8 @@ function level_position(input_array, level_target) {
276
276
  price = input_array[i][0]
277
277
  pos = i
278
278
  }
279
- return { price, avg_price: sum / vol ? sum / vol : price, vol, sum, pos }
279
+ const avg_price = sum / vol ? sum / vol : price
280
+ return { level: level_target, price, avg_price, vol, sum, pos }
280
281
  }
281
282
 
282
283
  function price_position(input_array, price) {
@@ -828,13 +829,31 @@ function number_with_commas(x) {
828
829
 
829
830
  function exchange_cur_quote_cur_converter(exchange_cur_quote_cur) {
830
831
  let exchange_pairs = {},
831
- exchange_curs = {}
832
+ exchange_curs = {},
833
+ exchange_cur_pairs = {}
832
834
  for (let exchange in exchange_cur_quote_cur) {
833
835
  _.set(exchange_pairs, [exchange], [])
834
836
  _.set(exchange_curs, [exchange], [])
837
+ _.set(exchange_cur_pairs, [exchange], {})
835
838
  for (let quote_cur in exchange_cur_quote_cur[exchange]) {
836
- exchange_pairs[exchange] = exchange_pairs[exchange].concat(_.map(exchange_cur_quote_cur[exchange][quote_cur], (cur) => cur + quote_cur))
839
+ const pairs_for_quote_cur = _.map(exchange_cur_quote_cur[exchange][quote_cur], (cur) => cur + quote_cur)
840
+ exchange_pairs[exchange] = exchange_pairs[exchange].concat(pairs_for_quote_cur)
837
841
  exchange_curs[exchange] = _.union(exchange_curs[exchange], _.union(exchange_cur_quote_cur[exchange][quote_cur], [quote_cur]))
842
+
843
+ // Build exchange_cur_pairs: map each currency to pairs containing it
844
+ for (let pair of pairs_for_quote_cur) {
845
+ const [cur] = parse_pair(pair)
846
+ // Add pair to cur (base currency)
847
+ if (!exchange_cur_pairs[exchange][cur]) {
848
+ exchange_cur_pairs[exchange][cur] = []
849
+ }
850
+ exchange_cur_pairs[exchange][cur].push(pair)
851
+ // Add pair to quote_cur
852
+ if (!exchange_cur_pairs[exchange][quote_cur]) {
853
+ exchange_cur_pairs[exchange][quote_cur] = []
854
+ }
855
+ exchange_cur_pairs[exchange][quote_cur].push(pair)
856
+ }
838
857
  }
839
858
  }
840
859
  let pair_exchanges = {}
@@ -885,6 +904,7 @@ function exchange_cur_quote_cur_converter(exchange_cur_quote_cur) {
885
904
  exchange_pairs_without_affiliates,
886
905
  exchange_curs,
887
906
  exchange_curs_without_affiliates,
907
+ exchange_cur_pairs,
888
908
  pair_exchanges,
889
909
  pair_exchanges_without_affiliates,
890
910
  exchange_affiliates,
@@ -956,5 +976,5 @@ module.exports = {
956
976
  number_with_commas,
957
977
  exchange_cur_quote_cur_converter,
958
978
  sort_keys,
959
- convert_deposit_withdrawal_chain
979
+ convert_deposit_withdrawal_chain,
960
980
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.9.36",
3
+ "version": "1.9.38",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -26,8 +26,6 @@
26
26
  "lodash": "^4.17.21",
27
27
  "mailgun-js": "^0.22.0",
28
28
  "needle": "^3.3.1",
29
- "websocket": "^1.0.35",
30
- "winston": "^2.4.5",
31
- "ws": "^8.18.3"
29
+ "winston": "^2.4.5"
32
30
  }
33
31
  }