@icgio/icg-exchanges-wrapper 1.14.208 → 1.14.210

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.
@@ -15,6 +15,7 @@ const get_exchanges_balance = function (exchanges, cb) {
15
15
  _.set(balances, exchange.settings.id, res.body)
16
16
  resolve()
17
17
  } else {
18
+ console.error(`getting balance ws failed for ${exchange.name}:`, res)
18
19
  delete balances[exchange.name]
19
20
  resolve()
20
21
  }
@@ -25,6 +26,7 @@ const get_exchanges_balance = function (exchanges, cb) {
25
26
  _.set(balances, exchange.settings.id, res.body)
26
27
  resolve()
27
28
  } else {
29
+ console.error(`getting balance failed for ${exchange.name}:`, res)
28
30
  delete balances[exchange.name]
29
31
  resolve()
30
32
  }
@@ -31,6 +31,7 @@ function get_exchanges_deposits(exchanges, client_currency, cb) {
31
31
  const deposits = JSON.parse(JSON.stringify(res.body))
32
32
  _.set(exchange_pair_deposits, [exchange_id], deposits)
33
33
  } else {
34
+ console.error(`getting all deposits failed for ${exchange_name}:`, res)
34
35
  delete exchange_pair_deposits[exchange_id]
35
36
  }
36
37
  _.set(deposits_status, [exchange_name], true)
@@ -47,6 +48,7 @@ function get_exchanges_deposits(exchanges, client_currency, cb) {
47
48
  const deposits = JSON.parse(JSON.stringify(res.body))
48
49
  _.set(exchange_pair_deposits, [exchange_id, pair], deposits)
49
50
  } else {
51
+ console.error(`getting deposits failed for ${exchange_name} ${pair}:`, res)
50
52
  delete exchange_pair_deposits[exchange_id][pair]
51
53
  }
52
54
  _.set(deposits_status, [exchange_name + pair], true)
@@ -42,6 +42,7 @@ const get_exchanges_open_orders = function (exchanges, exchange_pair_dict, cb, w
42
42
  const open_orders = res.body
43
43
  _.set(exchange_pair_open_orders, [exchange_id], open_orders)
44
44
  } else {
45
+ console.error(`getting open orders failed for ${exchange_name}:`, res)
45
46
  delete exchange_pair_open_orders[exchange_id]
46
47
  }
47
48
  _.set(open_orders_status, [exchange_name], true)
@@ -58,6 +59,7 @@ const get_exchanges_open_orders = function (exchanges, exchange_pair_dict, cb, w
58
59
  const open_orders = res.body
59
60
  _.set(exchange_pair_open_orders, [exchange_id, pair], open_orders)
60
61
  } else {
62
+ console.error(`getting open orders failed for ${exchange_name} ${pair}:`, res)
61
63
  if (exchange_pair_open_orders[exchange_id]) {
62
64
  delete exchange_pair_open_orders[exchange_id][pair]
63
65
  }
@@ -20,11 +20,9 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
20
20
  continue
21
21
  }
22
22
  checked_rates[Exchange_name] = true
23
-
24
23
  if (!exchange_pair_dict[Exchange_name]) {
25
24
  continue
26
25
  }
27
-
28
26
  if (Exchange.ws_market && ws_enabled) {
29
27
  let ws_promise = new Promise((resolve, reject) => {
30
28
  Exchange.ws_market(exchange_pair_dict[Exchange_name])
@@ -33,7 +31,6 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
33
31
  let all_pairs_opened = exchange_pair_dict[Exchange_name].every((pair) => {
34
32
  return Exchange.ws.market.pair_status[pair] === 'opened' && Exchange.ws.market.asks_dict[pair].length > 0 && Exchange.ws.market.bids_dict[pair].length > 0
35
33
  })
36
-
37
34
  if (all_pairs_opened) {
38
35
  let rate_promises = exchange_pair_dict[Exchange_name].map((pair) => {
39
36
  return new Promise((rate_resolve) => {
@@ -42,6 +39,7 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
42
39
  _.set(exchange_pair_rates, [Exchange_name, pair], res.body)
43
40
  _.set(pair_exchange_rates, [pair, Exchange_name], res.body)
44
41
  } else {
42
+ console.error(`getting rate ws failed for ${Exchange_name} ${pair}:`, res)
45
43
  if (exchange_pair_rates[Exchange_name]) {
46
44
  delete exchange_pair_rates[Exchange_name][pair]
47
45
  }
@@ -53,7 +51,6 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
53
51
  })
54
52
  })
55
53
  })
56
-
57
54
  Promise.all(rate_promises)
58
55
  .then(() => {
59
56
  // if (Exchange.ws.market.end_base) {
@@ -83,6 +80,7 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
83
80
  _.set(exchange_pair_rates, [Exchange_name, pair], res.body)
84
81
  _.set(pair_exchange_rates, [pair, Exchange_name], res.body)
85
82
  } else {
83
+ console.error(`getting rate failed for ${Exchange_name} ${pair}:`, res)
86
84
  if (exchange_pair_rates[Exchange_name]) {
87
85
  delete exchange_pair_rates[Exchange_name][pair]
88
86
  }
@@ -107,6 +105,7 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
107
105
  _.set(exchange_pair_rates, [Exchange_name, pair], { asks, bids })
108
106
  _.set(pair_exchange_rates, [pair, Exchange_name], { asks, bids })
109
107
  } else {
108
+ console.error(`getting rate with routes failed for ${Exchange_name} ${pair}:`, res)
110
109
  if (exchange_pair_rates[Exchange_name]) {
111
110
  delete exchange_pair_rates[Exchange_name][pair]
112
111
  }
@@ -150,23 +149,19 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
150
149
  continue
151
150
  }
152
151
  checked_market_history[Exchange_name] = true
153
-
154
152
  if (!exchange_pair_dict[Exchange_name]) {
155
153
  continue
156
154
  }
157
-
158
155
  if (Exchange.ws_market && ws_enabled) {
159
156
  let ws_promise = new Promise((resolve, reject) => {
160
157
  if (!first_time[Exchange_name]) {
161
158
  Exchange.ws_market(exchange_pair_dict[Exchange_name])
162
159
  first_time[Exchange_name] = true
163
160
  }
164
-
165
161
  const check_status = () => {
166
162
  let all_pairs_opened = exchange_pair_dict[Exchange_name].every((pair) => {
167
163
  return Exchange.ws.market.pair_status[pair] === 'opened' && Exchange.ws.market.market_history_dict[pair].length >= 0
168
164
  })
169
-
170
165
  if (all_pairs_opened) {
171
166
  let market_history_promises = exchange_pair_dict[Exchange_name].map((pair) => {
172
167
  return new Promise((rate_resolve) => {
@@ -175,6 +170,7 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
175
170
  _.set(exchange_pair_market_history, [Exchange_name, pair], res.body)
176
171
  _.set(pair_exchange_market_history, [pair, Exchange_name], res.body)
177
172
  } else {
173
+ console.error(`getting market history ws failed for ${Exchange_name} ${pair}:`, res)
178
174
  if (exchange_pair_market_history[Exchange_name]) {
179
175
  delete exchange_pair_market_history[Exchange_name][pair]
180
176
  }
@@ -186,7 +182,6 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
186
182
  })
187
183
  })
188
184
  })
189
-
190
185
  Promise.all(market_history_promises)
191
186
  .then(() => resolve())
192
187
  .catch((err) => {
@@ -197,10 +192,8 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
197
192
  setTimeout(check_status, 100)
198
193
  }
199
194
  }
200
-
201
195
  check_status()
202
196
  })
203
-
204
197
  promises.push(ws_promise)
205
198
  } else if (Exchange.market_history) {
206
199
  let market_history_promises = exchange_pair_dict[Exchange_name].map((pair) => {
@@ -210,6 +203,7 @@ const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, ti
210
203
  _.set(exchange_pair_market_history, [Exchange_name, pair], res.body)
211
204
  _.set(pair_exchange_market_history, [pair, Exchange_name], res.body)
212
205
  } else {
206
+ console.error(`getting market history failed for ${Exchange_name} ${pair}:`, res)
213
207
  if (exchange_pair_market_history[Exchange_name]) {
214
208
  delete exchange_pair_market_history[Exchange_name][pair]
215
209
  }
@@ -264,6 +258,7 @@ const get_exchanges_ohlcv = function (Exchanges, exchange_pair_dict, from_in_ms,
264
258
  _.set(exchange_pair_ohlcv, [Exchange_name, pair], res.body)
265
259
  _.set(pair_exchange_ohlcv, [pair, Exchange_name], res.body)
266
260
  } else {
261
+ console.error(`getting ohlcv failed for ${Exchange_name} ${pair}:`, res)
267
262
  if (exchange_pair_ohlcv[Exchange_name]) {
268
263
  delete exchange_pair_ohlcv[Exchange_name][pair]
269
264
  }
@@ -35,30 +35,7 @@ const get_exchanges_trades = function (exchanges, exchange_pair_dict, cb, ws_ena
35
35
 
36
36
  let trades_fetch_promises = []
37
37
 
38
- if (exchange && exchange.get_all_trades_ws) {
39
- if (exchange.ws_trades_status().trading === 'n-opened') {
40
- exchange.ws_account()
41
- }
42
-
43
- pair_list.forEach((pair) => {
44
- trades_fetch_promises.push(
45
- new Promise((resolve_pair, reject_pair) => {
46
- exchange.get_all_trades_ws(pair, TRADES_TIMEFRAME, function (res) {
47
- if (res.success) {
48
- const trades = res.body
49
- _.set(exchange_pair_trades, [exchange_id, pair], trades)
50
- } else {
51
- if (exchange_pair_trades[exchange_id]) {
52
- delete exchange_pair_trades[exchange_id][pair]
53
- }
54
- }
55
- _.set(trades_status, [exchange_name + pair], true)
56
- resolve_pair()
57
- })
58
- })
59
- )
60
- })
61
- } else if (exchange.get_all_trades) {
38
+ if (exchange.get_all_trades) {
62
39
  trades_fetch_promises.push(
63
40
  new Promise((resolve_pair, reject_pair) => {
64
41
  exchange.get_all_trades(pair, TRADES_TIMEFRAME, function (res) {
@@ -66,6 +43,7 @@ const get_exchanges_trades = function (exchanges, exchange_pair_dict, cb, ws_ena
66
43
  const trades = res.body
67
44
  _.set(exchange_pair_trades, [exchange_id, pair], trades)
68
45
  } else {
46
+ console.error(`getting all trades failed for ${exchange_name} ${pair}:`, res)
69
47
  if (exchange_pair_trades[exchange_id]) {
70
48
  delete exchange_pair_trades[exchange_id][pair]
71
49
  }
@@ -75,28 +53,6 @@ const get_exchanges_trades = function (exchanges, exchange_pair_dict, cb, ws_ena
75
53
  })
76
54
  })
77
55
  )
78
- } else if (exchange.get_trades_ws) {
79
- if (exchange.ws_trades_status().trading === 'n-opened') {
80
- exchange.ws_account()
81
- }
82
-
83
- pair_list.forEach((pair) => {
84
- trades_fetch_promises.push(
85
- new Promise((resolve_pair, reject_pair) => {
86
- exchange.get_trades_ws(pair, TRADES_TIMEFRAME, function (res) {
87
- if (res.success) {
88
- _.set(exchange_pair_trades, [exchange_id, pair], res.body)
89
- } else {
90
- if (exchange_pair_trades[exchange_id]) {
91
- delete exchange_pair_trades[exchange_id][pair]
92
- }
93
- }
94
- _.set(trades_status, [exchange_name + pair], true)
95
- resolve_pair()
96
- })
97
- })
98
- )
99
- })
100
56
  } else if (exchange.get_trades) {
101
57
  pair_list.forEach((pair) => {
102
58
  trades_fetch_promises.push(
@@ -106,6 +62,7 @@ const get_exchanges_trades = function (exchanges, exchange_pair_dict, cb, ws_ena
106
62
  const trades = res.body
107
63
  _.set(exchange_pair_trades, [exchange_id, pair], trades)
108
64
  } else {
65
+ console.error(`getting trades failed for ${exchange_name} ${pair}:`, res)
109
66
  if (exchange_pair_trades[exchange_id]) {
110
67
  delete exchange_pair_trades[exchange_id][pair]
111
68
  }
@@ -31,6 +31,7 @@ const get_exchanges_withdrawals = function (exchanges, client_currency, cb) {
31
31
  const withdrawals = JSON.parse(JSON.stringify(res.body))
32
32
  _.set(exchange_pair_withdrawals, [exchange_id], withdrawals)
33
33
  } else {
34
+ console.error(`getting all withdrawals failed for ${exchange_name}:`, res)
34
35
  delete exchange_pair_withdrawals[exchange_id]
35
36
  }
36
37
  _.set(withdrawals_status, [exchange_name], true)
@@ -47,6 +48,7 @@ const get_exchanges_withdrawals = function (exchanges, client_currency, cb) {
47
48
  const withdrawals = JSON.parse(JSON.stringify(res.body))
48
49
  _.set(exchange_pair_withdrawals, [exchange_id, pair], withdrawals)
49
50
  } else {
51
+ console.error(`getting withdrawals failed for ${exchange_name} ${pair}:`, res)
50
52
  delete exchange_pair_withdrawals[exchange_id][pair]
51
53
  }
52
54
  _.set(withdrawals_status, [exchange_name + pair], true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-exchanges-wrapper",
3
- "version": "1.14.208",
3
+ "version": "1.14.210",
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.32.108",
20
+ "@icgio/icg-exchanges": "^1.32.109",
21
21
  "@icgio/icg-exchanges-data": "^1.10.94",
22
22
  "@icgio/icg-utils": "^1.9.36",
23
23
  "influx": "^5.11.0",