@icgio/icg-exchanges-wrapper 1.17.2 → 1.17.4

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.
@@ -74,7 +74,6 @@ const TRADES_DEFAULT_MS = 7 * 24 * 60 * 60 * 1000
74
74
  const NO_CALLBACK_TIMEOUT_MS = 2 * 60 * 1000
75
75
  const PROCESS_RATES_THROTTLE_MS = 75
76
76
  const ORDER_TYPE_PRIORITY = {
77
- arb: 1,
78
77
  self: 2,
79
78
  maker_1: 3,
80
79
  maker_1_taker: 3,
@@ -136,8 +135,8 @@ module.exports = class Orders {
136
135
  this.no_cancel_previous_exchanges = settings.no_cancel_previous_exchanges || []
137
136
  this.no_cancel_range_exchanges = settings.no_cancel_range_exchanges || []
138
137
  this.no_trades_function_exchanges = settings.no_trades_function_exchanges || []
138
+ this.ws_market_options = settings.ws_market_options || {}
139
139
  this.no_trades_function_f_filled_timeout = 30 * 1000
140
- this.no_arb_exchanges = settings.no_arb_exchanges || []
141
140
  this.buy_sell_limits_threshold = 0.95
142
141
  this.p_filled_threshold = 0
143
142
  this.f_filled_threshold = 0.999
@@ -209,7 +208,6 @@ module.exports = class Orders {
209
208
  this.rates_combined_all = {}
210
209
  this.rates_combined_all_with_buy_sell_limits_against_reserve_balance = {}
211
210
  this.rates_combined_major = {}
212
- this.rates_combined_good_with_buy_sell_limits_against_reserve_balance = {}
213
211
  this.buy_sell_limits_against_reserve_balance = {}
214
212
  this.order_info = {}
215
213
  this.fill_records = [] // { side, usdt_amount, timestamp, order_type }
@@ -219,7 +217,7 @@ module.exports = class Orders {
219
217
  positions_check: false,
220
218
  open_orders_check: true,
221
219
  trades_check: true,
222
- query_order_check_arb_maker_1: true,
220
+ query_order_check_maker_1: true,
223
221
  query_order_check_exchange: {},
224
222
  rates_check: true,
225
223
  market_history_check: true,
@@ -239,7 +237,7 @@ module.exports = class Orders {
239
237
  this.trades_amount_past_hour = {}
240
238
  this.check_trades()
241
239
  }
242
- if (this.function_enabled.query_order_check_arb_maker_1) {
240
+ if (this.function_enabled.query_order_check_maker_1) {
243
241
  for (let exchange in this.Exchanges) {
244
242
  if (this.function_enabled.query_order_check_exchange[exchange]) {
245
243
  this.check_query_order(exchange)
@@ -264,7 +262,7 @@ module.exports = class Orders {
264
262
  this.process_open_orders(this.open_orders)
265
263
  }, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
266
264
  }
267
- if (this.function_enabled.query_order_check_arb_maker_1) {
265
+ if (this.function_enabled.query_order_check_maker_1) {
268
266
  setInterval(() => {
269
267
  this.process_query_order(this.query_order)
270
268
  }, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
@@ -840,7 +838,7 @@ module.exports = class Orders {
840
838
  // Track fill amounts for imbalance detection
841
839
  if (dict.status === 'F-FILLED') {
842
840
  const order_info_full = _.get(this.order_info, [exchange, pair, type, order_id], {})
843
- const tracked_types = ['maker_1', 'maker_2', 'maker_3', 'arb']
841
+ const tracked_types = ['maker_1', 'maker_2', 'maker_3']
844
842
  if (tracked_types.includes(order_info_full.order_type)) {
845
843
  const usdt_amount = order_info_full.f_amount * order_info_full.price
846
844
  this.fill_records.push({
@@ -1040,12 +1038,12 @@ module.exports = class Orders {
1040
1038
  if (this.cancel_range_orders && !_.includes(this.major_exchanges[pair], exchange) && !_.includes(this.no_cancel_range_exchanges, exchange) && rate_major) {
1041
1039
  // console.log(exchange, pair, rate_major, orders)
1042
1040
  orders.map((order) => {
1043
- if (order.type === 'sell' && order.price < rate_major.asks[0][0] && order.order_status !== 'F-FILLED' && order.order_type !== 'arb' && order.order_type !== 'manual') {
1041
+ if (order.type === 'sell' && order.price < rate_major.asks[0][0] && order.order_status !== 'F-FILLED' && order.order_type !== 'manual') {
1044
1042
  console.log('cancel range order: %s %s %j', exchange, pair, order)
1045
1043
  order.order_type = 'range-order'
1046
1044
  this.cancel_order(exchange, pair, order)
1047
1045
  }
1048
- if (order.type === 'buy' && order.price > rate_major.bids[0][0] && order.order_status !== 'F-FILLED' && order.order_type !== 'arb' && order.order_type !== 'manual') {
1046
+ if (order.type === 'buy' && order.price > rate_major.bids[0][0] && order.order_status !== 'F-FILLED' && order.order_type !== 'manual') {
1049
1047
  console.log('cancel range order: %s %s %j', exchange, pair, order)
1050
1048
  order.order_type = 'range-order'
1051
1049
  this.cancel_order(exchange, pair, order)
@@ -1296,7 +1294,7 @@ module.exports = class Orders {
1296
1294
  }
1297
1295
  let get_query_order_all = (Exchanges, exchange_pairs, interval_dict) => {
1298
1296
  let query_order = (exchange, pair) => {
1299
- let order_info = _.get(this.get_order_info_by_order_type(['arb', 'maker_1']), [exchange, pair], {})
1297
+ let order_info = _.get(this.get_order_info_by_order_type(['maker_1']), [exchange, pair], {})
1300
1298
  let timeout = setTimeout(() => {
1301
1299
  query_order(exchange, pair)
1302
1300
  }, interval_dict[exchange].query_order)
@@ -1308,7 +1306,7 @@ module.exports = class Orders {
1308
1306
  let { open_time } = order_info[type][order_id]
1309
1307
  // console.log(order_id, open_time, open_time < new Date() - 30 * 60 * 1000)
1310
1308
  if (open_time < new Date() - QUERY_ORDER_TIME_IN_MS) {
1311
- // console.log('query_order_arb_maker_1: %s %s %s', exchange, pair, order_id)
1309
+ // console.log('query_order_maker_1: %s %s %s', exchange, pair, order_id)
1312
1310
  Exchanges[exchange].query_order(pair, order_id, (res) => {
1313
1311
  count++
1314
1312
  if (res.success) {
@@ -1343,9 +1341,7 @@ module.exports = class Orders {
1343
1341
  let orderbook_all = {},
1344
1342
  orderbook_all_with_buy_sell_limits_against_reserve_balance = {},
1345
1343
  orderbook_major = {},
1346
- orderbook_major_temp = {},
1347
- orderbook_good_with_buy_sell_limits_against_reserve_balance = {},
1348
- orderbook_good_temp = {}
1344
+ orderbook_major_temp = {}
1349
1345
  let exchanges_list = _.concat(this.pair_exchanges[pair] || [], this.pair_exchanges_rates_only[pair] || [])
1350
1346
  for (let exchange of exchanges_list) {
1351
1347
  if (_.get(this.rates, [exchange, pair, 'asks'], []).length > 0 && _.get(this.rates, [exchange, pair, 'bids'], []).length > 0) {
@@ -1379,17 +1375,8 @@ module.exports = class Orders {
1379
1375
  bids: utils.vol_position_orderbook(rates.bids, this.buy_sell_limits_against_reserve_balance[exchange][pair].sell),
1380
1376
  }
1381
1377
  orderbook_all_with_buy_sell_limits_against_reserve_balance[exchange] = rates_with_buy_sell_limits_against_reserve_balance
1382
-
1383
- if (!_.includes(this.no_arb_exchanges, exchange) || !this.exchange_pairs_rates_only[exchange]) {
1384
- orderbook_good_temp[exchange] = rates_with_buy_sell_limits_against_reserve_balance
1385
- if (_.keys(orderbook_good_temp).length === this.pair_exchanges[pair].length - this.no_arb_exchanges.length) {
1386
- orderbook_good_with_buy_sell_limits_against_reserve_balance = orderbook_good_temp
1387
- }
1388
- }
1389
1378
  } else {
1390
1379
  orderbook_all_with_buy_sell_limits_against_reserve_balance = _.omit(orderbook_all_with_buy_sell_limits_against_reserve_balance, [exchange])
1391
- orderbook_good_with_buy_sell_limits_against_reserve_balance = _.omit(orderbook_good_with_buy_sell_limits_against_reserve_balance, [exchange])
1392
- orderbook_good_temp = _.omit(orderbook_good_temp, [exchange])
1393
1380
  }
1394
1381
  } else {
1395
1382
  orderbook_major = _.omit(orderbook_major, [exchange])
@@ -1418,12 +1405,6 @@ module.exports = class Orders {
1418
1405
  this.rates_combined_major = _.omit(this.rates_combined_major, [pair])
1419
1406
  }
1420
1407
 
1421
- let o_4 = utils.combine_orderbooks(orderbook_good_with_buy_sell_limits_against_reserve_balance, COMBINE_ORDERBOOKS_LEVEL)
1422
- if (o_4.asks.length > 0 && o_4.bids.length > 0) {
1423
- _.set(this.rates_combined_good_with_buy_sell_limits_against_reserve_balance, [pair], o_4)
1424
- } else {
1425
- this.rates_combined_good_with_buy_sell_limits_against_reserve_balance = _.omit(this.rates_combined_good_with_buy_sell_limits_against_reserve_balance, [pair])
1426
- }
1427
1408
  const reference_pair = this.pair_map_rates_only[pair]
1428
1409
  if (this.pair_map_rates_only[pair] && this.rates_combined_major[reference_pair]) {
1429
1410
  this.rates_combined_major[pair] = this.rates_combined_major[reference_pair]
@@ -1460,7 +1441,7 @@ module.exports = class Orders {
1460
1441
  for (let exchange in exchange_pairs) {
1461
1442
  if (Exchanges[exchange].ws_market && Exchanges[exchange].exchange_type === 'spot') {
1462
1443
  if (!this.ws_market_first_time[exchange]) {
1463
- Exchanges[exchange].ws_market(exchange_pairs[exchange])
1444
+ Exchanges[exchange].ws_market(exchange_pairs[exchange], this.ws_market_options)
1464
1445
  this.ws_market_first_time[exchange] = true
1465
1446
  }
1466
1447
  for (let pair of exchange_pairs[exchange]) {
@@ -1471,7 +1452,7 @@ module.exports = class Orders {
1471
1452
  } else if (Exchanges[exchange].ws_market && Exchanges[exchange].exchange_type === 'dex') {
1472
1453
  setInterval(() => {
1473
1454
  if (!this.ws_market_first_time[exchange]) {
1474
- Exchanges[exchange].ws_market(exchange_pairs[exchange])
1455
+ Exchanges[exchange].ws_market(exchange_pairs[exchange], this.ws_market_options)
1475
1456
  this.ws_market_first_time[exchange] = true
1476
1457
  } else {
1477
1458
  for (let pair of exchange_pairs[exchange]) {
@@ -1502,11 +1483,11 @@ module.exports = class Orders {
1502
1483
  for (let exchange in exchange_pairs_rates_only) {
1503
1484
  if (ExchangesRatesOnly[exchange].ws_market) {
1504
1485
  if (!this.ws_market_first_time[exchange]) {
1505
- ExchangesRatesOnly[exchange].ws_market(exchange_pairs_rates_only[exchange])
1486
+ ExchangesRatesOnly[exchange].ws_market(exchange_pairs_rates_only[exchange], { bbo: true, depth: false, trades: false })
1506
1487
  this.ws_market_first_time[exchange] = true
1507
1488
  }
1508
1489
  for (let pair of exchange_pairs_rates_only[exchange]) {
1509
- ExchangesRatesOnly[exchange].rate_ws_top_observable(pair, (res) => {
1490
+ ExchangesRatesOnly[exchange].bbo_ws_observable(pair, (res) => {
1510
1491
  rates_handler(exchange, pair, res)
1511
1492
  })
1512
1493
  }
@@ -1537,7 +1518,7 @@ module.exports = class Orders {
1537
1518
  const market_history_timeframe = exchange === 'coinbene' ? 30 * 24 * 60 * 60 * 1000 : MARKET_HISTORY_DEFAULT_MS
1538
1519
  if (Exchanges[exchange].ws_market && Exchanges[exchange].exchange_type === 'spot') {
1539
1520
  if (!this.ws_market_first_time[exchange]) {
1540
- Exchanges[exchange].ws_market(exchange_pairs[exchange])
1521
+ Exchanges[exchange].ws_market(exchange_pairs[exchange], this.ws_market_options)
1541
1522
  this.ws_market_first_time[exchange] = true
1542
1523
  }
1543
1524
  for (let pair of exchange_pairs[exchange]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-exchanges-wrapper",
3
- "version": "1.17.2",
3
+ "version": "1.17.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
19
19
  "dependencies": {
20
- "@icgio/icg-exchanges": "^1.40.2",
21
- "@icgio/icg-utils": "^1.9.52",
20
+ "@icgio/icg-exchanges": "^1.40.3",
21
+ "@icgio/icg-utils": "^1.9.53",
22
22
  "lodash": "^4.17.23",
23
23
  "pg": "^8.17.2"
24
24
  }