@icgio/icg-exchanges-wrapper 1.21.46 → 1.22.0
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 +57 -3
- package/package.json +2 -2
package/middleware/orders.js
CHANGED
|
@@ -187,7 +187,7 @@ module.exports = class Orders {
|
|
|
187
187
|
limits
|
|
188
188
|
if (_.includes(['hkbitex'], exchange_base)) {
|
|
189
189
|
limits = HKBITEX_LIMITS
|
|
190
|
-
} else if (_.includes(['binance', '
|
|
190
|
+
} else if (_.includes(['binance', 'binancefutures', 'gate'], exchange_base)) {
|
|
191
191
|
limits = MEDIUM_LIMITS
|
|
192
192
|
} else if (_.includes(['bitfinex', 'hashkeyglobal', 'kucoin', 'lbank', 'okx', 'phemex', 'xt'], exchange_base)) {
|
|
193
193
|
limits = SMALL_LIMITS
|
|
@@ -1144,6 +1144,18 @@ module.exports = class Orders {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
1146
|
function get_balances(Exchanges, interval_dict) {
|
|
1147
|
+
// push tier: observables fire on account events; the poll loops below remain the watchdog
|
|
1148
|
+
for (let exchange in Exchanges) {
|
|
1149
|
+
if (!Exchanges[exchange].balance_ws_observable) {
|
|
1150
|
+
continue
|
|
1151
|
+
}
|
|
1152
|
+
if (Exchanges[exchange].ws_status().trading === 'n-opened') {
|
|
1153
|
+
Exchanges[exchange].ws_account()
|
|
1154
|
+
}
|
|
1155
|
+
Exchanges[exchange].balance_ws_observable((res) => {
|
|
1156
|
+
balances_handler(exchange, res)
|
|
1157
|
+
})
|
|
1158
|
+
}
|
|
1147
1159
|
for (let exchange in Exchanges) {
|
|
1148
1160
|
if (Exchanges[exchange].balance_ws) {
|
|
1149
1161
|
setInterval(() => {
|
|
@@ -1174,6 +1186,18 @@ module.exports = class Orders {
|
|
|
1174
1186
|
}
|
|
1175
1187
|
}
|
|
1176
1188
|
function get_positions(Exchanges, interval_dict) {
|
|
1189
|
+
// push tier (see get_balances)
|
|
1190
|
+
for (let exchange in Exchanges) {
|
|
1191
|
+
if (!Exchanges[exchange].position_all_ws_observable) {
|
|
1192
|
+
continue
|
|
1193
|
+
}
|
|
1194
|
+
if (Exchanges[exchange].ws_status().trading === 'n-opened') {
|
|
1195
|
+
Exchanges[exchange].ws_account()
|
|
1196
|
+
}
|
|
1197
|
+
Exchanges[exchange].position_all_ws_observable((res) => {
|
|
1198
|
+
position_all_handler(exchange, res)
|
|
1199
|
+
})
|
|
1200
|
+
}
|
|
1177
1201
|
for (let exchange in Exchanges) {
|
|
1178
1202
|
if (Exchanges[exchange].position_all_ws) {
|
|
1179
1203
|
if (Exchanges[exchange].ws_status().trading === 'n-opened') Exchanges[exchange].ws_account()
|
|
@@ -1302,8 +1326,7 @@ module.exports = class Orders {
|
|
|
1302
1326
|
else live_ids.add(String(order.order_id))
|
|
1303
1327
|
})
|
|
1304
1328
|
const unexpected_ids = new Set(Array.from(live_ids).filter((order_id) => !state.orders_by_id.has(order_id)))
|
|
1305
|
-
const unexpected_ids_changed =
|
|
1306
|
-
unexpected_ids.size !== state.unexpected_ids.size || Array.from(unexpected_ids).some((order_id) => !state.unexpected_ids.has(order_id))
|
|
1329
|
+
const unexpected_ids_changed = unexpected_ids.size !== state.unexpected_ids.size || Array.from(unexpected_ids).some((order_id) => !state.unexpected_ids.has(order_id))
|
|
1307
1330
|
if (unexpected_ids.size > 0 && unexpected_ids_changed) {
|
|
1308
1331
|
console.error('unexpected orders during original cleanup: %s %s count=%s order_ids=%j', exchange, pair, unexpected_ids.size, Array.from(unexpected_ids).slice(0, 10))
|
|
1309
1332
|
}
|
|
@@ -1410,6 +1433,20 @@ module.exports = class Orders {
|
|
|
1410
1433
|
}, interval_dict[exchange].open_orders)
|
|
1411
1434
|
})
|
|
1412
1435
|
}
|
|
1436
|
+
// push tier (see get_balances)
|
|
1437
|
+
for (let exchange in Exchanges) {
|
|
1438
|
+
if (!Exchanges[exchange].open_orders_ws_observable) {
|
|
1439
|
+
continue
|
|
1440
|
+
}
|
|
1441
|
+
if (Exchanges[exchange].ws_status().trading === 'n-opened') {
|
|
1442
|
+
Exchanges[exchange].ws_account()
|
|
1443
|
+
}
|
|
1444
|
+
for (let pair of exchange_pairs[exchange]) {
|
|
1445
|
+
Exchanges[exchange].open_orders_ws_observable(pair, (res) => {
|
|
1446
|
+
open_orders_handler(exchange, pair, res)
|
|
1447
|
+
})
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1413
1450
|
for (let exchange in Exchanges) {
|
|
1414
1451
|
if (Exchanges[exchange].get_all_open_orders_ws) {
|
|
1415
1452
|
if (Exchanges[exchange].ws_status().trading === 'n-opened') Exchanges[exchange].ws_account()
|
|
@@ -1540,6 +1577,23 @@ module.exports = class Orders {
|
|
|
1540
1577
|
}
|
|
1541
1578
|
}
|
|
1542
1579
|
}
|
|
1580
|
+
// push tier (see get_balances)
|
|
1581
|
+
for (let exchange in Exchanges) {
|
|
1582
|
+
if (_.includes(this.no_trades_function_exchanges, exchange)) {
|
|
1583
|
+
continue
|
|
1584
|
+
}
|
|
1585
|
+
if (!Exchanges[exchange].trades_ws_observable) {
|
|
1586
|
+
continue
|
|
1587
|
+
}
|
|
1588
|
+
if (Exchanges[exchange].ws_status().trading === 'n-opened') {
|
|
1589
|
+
Exchanges[exchange].ws_account()
|
|
1590
|
+
}
|
|
1591
|
+
for (let pair of exchange_pairs[exchange]) {
|
|
1592
|
+
Exchanges[exchange].trades_ws_observable(pair, TRADES_DEFAULT_MS, (res) => {
|
|
1593
|
+
trades_handler(exchange, pair, res)
|
|
1594
|
+
})
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1543
1597
|
for (let exchange in Exchanges) {
|
|
1544
1598
|
if (_.includes(this.no_trades_function_exchanges, exchange)) {
|
|
1545
1599
|
} else if (Exchanges[exchange].get_all_trades_ws) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-exchanges-wrapper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
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.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.48.0",
|
|
21
21
|
"@icgio/icg-utils": "^1.9.64",
|
|
22
22
|
"lodash": "^4.17.23",
|
|
23
23
|
"pg": "^8.17.2"
|