@icgio/icg-exchanges-wrapper 1.14.24 → 1.14.25
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 +14 -8
- package/package.json +2 -2
package/middleware/orders.js
CHANGED
|
@@ -55,13 +55,14 @@ const MARKET_HISTORY_DEFAULT_TIME = 10 * 60 * 1000
|
|
|
55
55
|
const TRADES_DEFAULT_TIME = 7 * 24 * 60 * 60 * 1000
|
|
56
56
|
const NO_CALLBACK_TIMEOUT = 2 * 60 * 1000
|
|
57
57
|
const COMBINE_ORDERBOOKS_LEVEL = 100
|
|
58
|
+
const PROCESS_RATES_THROTTLE = 10
|
|
58
59
|
|
|
59
60
|
module.exports = class Orders {
|
|
60
61
|
constructor(exchange_cur_quote_cur_dict, cd, settings) {
|
|
61
62
|
let { exchange_cur_quote_cur, exchange_cur_quote_cur_rates_only, pair_map_rates_only } = exchange_cur_quote_cur_dict
|
|
62
63
|
this.exchange_cur_quote_cur = exchange_cur_quote_cur
|
|
63
64
|
this.exchange_cur_quote_cur_rates_only = exchange_cur_quote_cur_rates_only
|
|
64
|
-
this.pair_map_rates_only = pair_map_rates_only
|
|
65
|
+
this.pair_map_rates_only = pair_map_rates_only || {}
|
|
65
66
|
let { exchange_pairs, pair_exchanges } = utils.exchange_cur_quote_cur_converter(exchange_cur_quote_cur)
|
|
66
67
|
let { exchange_pairs: exchange_pairs_rates_only, pair_exchanges: pair_exchanges_rates_only } = utils.exchange_cur_quote_cur_converter(exchange_cur_quote_cur_rates_only)
|
|
67
68
|
this.exchange_pairs = exchange_pairs
|
|
@@ -1209,7 +1210,7 @@ module.exports = class Orders {
|
|
|
1209
1210
|
orderbook_all = _.omit(orderbook_all, [exchange])
|
|
1210
1211
|
}
|
|
1211
1212
|
if (_.get(this.rates, [exchange, pair, 'asks'], []).length > 0 && _.get(this.rates, [exchange, pair, 'bids'], []).length > 0) {
|
|
1212
|
-
|
|
1213
|
+
const rates = _.cloneDeep(this.rates[exchange][pair])
|
|
1213
1214
|
|
|
1214
1215
|
let major_rates_only_exchanges_length = this.major_exchanges[pair].length + _.get(this.rates_only_exchanges, [pair], []).length
|
|
1215
1216
|
if (this.major_exchanges[pair] && _.includes(this.major_exchanges[pair], exchange)) {
|
|
@@ -1279,8 +1280,14 @@ module.exports = class Orders {
|
|
|
1279
1280
|
} else {
|
|
1280
1281
|
this.rates_combined_good_with_buy_sell_limits_against_reserve_balance = _.omit(this.rates_combined_good_with_buy_sell_limits_against_reserve_balance, [pair])
|
|
1281
1282
|
}
|
|
1283
|
+
if (this.pair_map_rates_only[pair]) {
|
|
1284
|
+
const reference_pair = this.pair_map_rates_only[pair]
|
|
1285
|
+
this.rates_combined_major[reference_pair] = this.rates_combined_major[pair]
|
|
1286
|
+
}
|
|
1282
1287
|
}
|
|
1288
|
+
this.rates_observable.notify()
|
|
1283
1289
|
}
|
|
1290
|
+
const throttled_process_rates = _.throttle(process_rates, PROCESS_RATES_THROTTLE, { leading: true, trailing: true })
|
|
1284
1291
|
let rates_handler = (exchange, pair, res, rates_with_routes = false) => {
|
|
1285
1292
|
if (res.success) {
|
|
1286
1293
|
let { asks, bids } = res.body
|
|
@@ -1292,16 +1299,15 @@ module.exports = class Orders {
|
|
|
1292
1299
|
asks = asks.slice(0, RATES_LENGTH_MAX)
|
|
1293
1300
|
bids = bids.slice(0, RATES_LENGTH_MAX)
|
|
1294
1301
|
_.set(this.rates, [exchange, pair], { asks, bids, update_time: new Date() })
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1302
|
+
/*
|
|
1303
|
+
* throttle to 10ms
|
|
1304
|
+
*/
|
|
1305
|
+
throttled_process_rates()
|
|
1300
1306
|
} else if (_.get(this.rates, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].rates) {
|
|
1301
1307
|
this.info_log('%s %s rates expired: %j', exchange, pair, res)
|
|
1302
1308
|
this.rates[exchange] = _.omit(this.rates[exchange], [pair])
|
|
1309
|
+
this.rates_observable.notify()
|
|
1303
1310
|
}
|
|
1304
|
-
this.rates_observable.notify()
|
|
1305
1311
|
}
|
|
1306
1312
|
let get_rates = (Exchanges, ExchangesRatesOnly, exchange_pairs, exchange_pairs_rates_only, interval_dict) => {
|
|
1307
1313
|
if (!this.ws_market_first_time) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-exchanges-wrapper",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.25",
|
|
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.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.32.22",
|
|
21
21
|
"@icgio/icg-exchanges-data": "^1.10.11",
|
|
22
22
|
"@icgio/icg-utils": "^1.9.13",
|
|
23
23
|
"influx": "^5.10.0",
|