@icgio/icg-exchanges-wrapper 1.14.31 → 1.14.32
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.
- package/middleware/orders.js +16 -15
- package/package.json +1 -1
package/middleware/orders.js
CHANGED
|
@@ -48,14 +48,15 @@ const P2B_LIMITS = {
|
|
|
48
48
|
private_interval_concurrent: 200,
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const PROCESS_INTERVAL = 1000
|
|
52
51
|
const RATES_LENGTH_MAX = 100
|
|
53
52
|
const RATES_LENGTH_DEFAULT = 50
|
|
54
|
-
const MARKET_HISTORY_DEFAULT_TIME = 10 * 60 * 1000
|
|
55
|
-
const TRADES_DEFAULT_TIME = 7 * 24 * 60 * 60 * 1000
|
|
56
|
-
const NO_CALLBACK_TIMEOUT = 2 * 60 * 1000
|
|
57
53
|
const COMBINE_ORDERBOOKS_LEVEL = 100
|
|
58
|
-
|
|
54
|
+
|
|
55
|
+
const PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS = 500
|
|
56
|
+
const MARKET_HISTORY_DEFAULT_MS = 10 * 60 * 1000
|
|
57
|
+
const TRADES_DEFAULT_MS = 7 * 24 * 60 * 60 * 1000
|
|
58
|
+
const NO_CALLBACK_TIMEOUT_MS = 2 * 60 * 1000
|
|
59
|
+
const PROCESS_RATES_THROTTLE_MS = 30
|
|
59
60
|
|
|
60
61
|
module.exports = class Orders {
|
|
61
62
|
constructor(exchange_cur_quote_cur_dict, cd, settings) {
|
|
@@ -220,12 +221,12 @@ module.exports = class Orders {
|
|
|
220
221
|
setInterval(() => {
|
|
221
222
|
this.process_trades(this.trades)
|
|
222
223
|
this.process_open_orders(this.open_orders)
|
|
223
|
-
},
|
|
224
|
+
}, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
|
|
224
225
|
}
|
|
225
226
|
if (this.function_enabled.query_order_check) {
|
|
226
227
|
setInterval(() => {
|
|
227
228
|
this.process_query_order(this.query_order)
|
|
228
|
-
},
|
|
229
|
+
}, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
232
|
init_account(balances, benchmarks) {
|
|
@@ -273,7 +274,7 @@ module.exports = class Orders {
|
|
|
273
274
|
order_type + ' n-opened-timeout-init'
|
|
274
275
|
)
|
|
275
276
|
}
|
|
276
|
-
},
|
|
277
|
+
}, NO_CALLBACK_TIMEOUT_MS)
|
|
277
278
|
let limit_trade = (cb) => {
|
|
278
279
|
if (this.Exchanges[exchange].exchange_type === 'dex') {
|
|
279
280
|
let rates_with_routes = this.rates_with_routes[exchange][pair]
|
|
@@ -1057,7 +1058,7 @@ module.exports = class Orders {
|
|
|
1057
1058
|
let get_trades_all = (Exchanges, exchange_pairs, interval_dict) => {
|
|
1058
1059
|
let get_all_trades_ws = (exchange) => {
|
|
1059
1060
|
if (Exchanges[exchange].ws_status().trading === 'n-opened') Exchanges[exchange].ws_account()
|
|
1060
|
-
Exchanges[exchange].get_all_trades_ws(
|
|
1061
|
+
Exchanges[exchange].get_all_trades_ws(TRADES_DEFAULT_MS, (res) => {
|
|
1061
1062
|
all_trades_handler(exchange, res)
|
|
1062
1063
|
setTimeout(() => {
|
|
1063
1064
|
get_all_trades_ws(exchange)
|
|
@@ -1065,7 +1066,7 @@ module.exports = class Orders {
|
|
|
1065
1066
|
})
|
|
1066
1067
|
}
|
|
1067
1068
|
let get_trades_ws = (exchange, pair) => {
|
|
1068
|
-
Exchanges[exchange].get_trades_ws(pair,
|
|
1069
|
+
Exchanges[exchange].get_trades_ws(pair, TRADES_DEFAULT_MS, (res) => {
|
|
1069
1070
|
trades_handler(exchange, pair, res)
|
|
1070
1071
|
setTimeout(() => {
|
|
1071
1072
|
get_trades_ws(exchange, pair)
|
|
@@ -1073,7 +1074,7 @@ module.exports = class Orders {
|
|
|
1073
1074
|
})
|
|
1074
1075
|
}
|
|
1075
1076
|
let get_all_trades = (exchange) => {
|
|
1076
|
-
Exchanges[exchange].get_all_trades(
|
|
1077
|
+
Exchanges[exchange].get_all_trades(TRADES_DEFAULT_MS, (res) => {
|
|
1077
1078
|
all_trades_handler(exchange, res)
|
|
1078
1079
|
setTimeout(() => {
|
|
1079
1080
|
get_all_trades(exchange)
|
|
@@ -1081,7 +1082,7 @@ module.exports = class Orders {
|
|
|
1081
1082
|
})
|
|
1082
1083
|
}
|
|
1083
1084
|
let get_trades = (exchange, pair) => {
|
|
1084
|
-
Exchanges[exchange].get_trades(pair,
|
|
1085
|
+
Exchanges[exchange].get_trades(pair, TRADES_DEFAULT_MS, (res) => {
|
|
1085
1086
|
trades_handler(exchange, pair, res)
|
|
1086
1087
|
setTimeout(() => {
|
|
1087
1088
|
get_trades(exchange, pair)
|
|
@@ -1098,7 +1099,7 @@ module.exports = class Orders {
|
|
|
1098
1099
|
result = []
|
|
1099
1100
|
for (let type in order_info) {
|
|
1100
1101
|
for (let order_id in order_info[type]) {
|
|
1101
|
-
Exchanges[exchange].get_trades_id(pair, order_id,
|
|
1102
|
+
Exchanges[exchange].get_trades_id(pair, order_id, TRADES_DEFAULT_MS, (res) => {
|
|
1102
1103
|
count++
|
|
1103
1104
|
if (res.success) {
|
|
1104
1105
|
result = res.body.concat(result)
|
|
@@ -1287,7 +1288,7 @@ module.exports = class Orders {
|
|
|
1287
1288
|
}
|
|
1288
1289
|
this.rates_observable.notify()
|
|
1289
1290
|
}
|
|
1290
|
-
const throttled_process_rates = _.throttle(process_rates,
|
|
1291
|
+
const throttled_process_rates = _.throttle(process_rates, PROCESS_RATES_THROTTLE_MS, { leading: true, trailing: true })
|
|
1291
1292
|
let rates_handler = (exchange, pair, res, rates_with_routes = false) => {
|
|
1292
1293
|
if (res.success) {
|
|
1293
1294
|
let { asks, bids } = res.body
|
|
@@ -1390,7 +1391,7 @@ module.exports = class Orders {
|
|
|
1390
1391
|
}
|
|
1391
1392
|
let get_market_history = (Exchanges, exchange_pairs, interval_dict) => {
|
|
1392
1393
|
for (let exchange in Exchanges) {
|
|
1393
|
-
const market_history_timeframe = exchange === 'coinbene' ? 30 * 24 * 60 * 60 * 1000 :
|
|
1394
|
+
const market_history_timeframe = exchange === 'coinbene' ? 30 * 24 * 60 * 60 * 1000 : MARKET_HISTORY_DEFAULT_MS
|
|
1394
1395
|
if (Exchanges[exchange].ws_market && Exchanges[exchange].exchange_type === 'spot') {
|
|
1395
1396
|
if (!this.ws_market_first_time[exchange]) {
|
|
1396
1397
|
Exchanges[exchange].ws_market(exchange_pairs[exchange])
|