@icgio/icg-exchanges-wrapper 1.14.170 → 1.14.172
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 +21 -21
- package/package.json +1 -1
package/middleware/orders.js
CHANGED
|
@@ -181,7 +181,7 @@ module.exports = class Orders {
|
|
|
181
181
|
positions_check: false,
|
|
182
182
|
open_orders_check: true,
|
|
183
183
|
trades_check: true,
|
|
184
|
-
|
|
184
|
+
query_order_check_old_orders: true,
|
|
185
185
|
query_order_check_exchange: {},
|
|
186
186
|
rates_check: true,
|
|
187
187
|
market_history_check: true,
|
|
@@ -201,7 +201,7 @@ module.exports = class Orders {
|
|
|
201
201
|
this.trades_amount_past_hour = {}
|
|
202
202
|
this.check_trades()
|
|
203
203
|
}
|
|
204
|
-
if (this.function_enabled.
|
|
204
|
+
if (this.function_enabled.query_order_check_old_orders) {
|
|
205
205
|
for (let exchange in this.Exchanges) {
|
|
206
206
|
if (this.function_enabled.query_order_check_exchange[exchange]) {
|
|
207
207
|
this.check_query_order(exchange)
|
|
@@ -226,7 +226,7 @@ module.exports = class Orders {
|
|
|
226
226
|
this.process_open_orders(this.open_orders)
|
|
227
227
|
}, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
|
|
228
228
|
}
|
|
229
|
-
if (this.function_enabled.
|
|
229
|
+
if (this.function_enabled.query_order_check_old_orders) {
|
|
230
230
|
setInterval(() => {
|
|
231
231
|
this.process_query_order(this.query_order)
|
|
232
232
|
}, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
|
|
@@ -865,25 +865,24 @@ module.exports = class Orders {
|
|
|
865
865
|
if (_.includes(this.no_cancel_previous_exchanges, exchange) && !this.previous_orders_canceled) {
|
|
866
866
|
_.set(this.previous_orders_canceled_exchange_pair, [exchange, pair], true)
|
|
867
867
|
}
|
|
868
|
-
// cancel previous orders with delay
|
|
869
|
-
else if (this.cancel_previous_orders && this.cancel_previous_orders_with_delay) {
|
|
870
|
-
const previous_orders = _.cloneDeep(orders)
|
|
871
|
-
setTimeout(() => {
|
|
872
|
-
previous_orders.map((order) => {
|
|
873
|
-
console.log('cancel original order: %s %s %j', exchange, pair, order)
|
|
874
|
-
this.Exchanges[exchange].cancel_order_by_order(order, (res) => {})
|
|
875
|
-
})
|
|
876
|
-
}, CANCEL_PREVIOUS_ORDERS_DELAY_MS)
|
|
877
|
-
this.previous_orders_canceled = true
|
|
878
|
-
}
|
|
879
868
|
// cancel previous orders
|
|
880
869
|
else if (this.cancel_previous_orders && !this.previous_orders_canceled) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
870
|
+
if (this.cancel_previous_orders_with_delay) {
|
|
871
|
+
setTimeout(() => {
|
|
872
|
+
orders.map((order) => {
|
|
873
|
+
console.log('cancel original order with delay: %s %s %j', exchange, pair, order)
|
|
874
|
+
this.Exchanges[exchange].cancel_order_by_order(order, (res) => {})
|
|
875
|
+
})
|
|
876
|
+
}, CANCEL_PREVIOUS_ORDERS_DELAY_MS)
|
|
886
877
|
_.set(this.previous_orders_canceled_exchange_pair, [exchange, pair], true)
|
|
878
|
+
} else {
|
|
879
|
+
orders.map((order) => {
|
|
880
|
+
console.log('cancel original order: %s %s %j', exchange, pair, order)
|
|
881
|
+
this.Exchanges[exchange].cancel_order_by_order(order, (res) => {})
|
|
882
|
+
})
|
|
883
|
+
if (orders.length === 0) {
|
|
884
|
+
_.set(this.previous_orders_canceled_exchange_pair, [exchange, pair], true)
|
|
885
|
+
}
|
|
887
886
|
}
|
|
888
887
|
if (!this.previous_orders_canceled) {
|
|
889
888
|
let previous_orders_canceled = true
|
|
@@ -1146,8 +1145,8 @@ module.exports = class Orders {
|
|
|
1146
1145
|
get_trades_all(this.Exchanges, this.exchange_pairs, this.interval_dict)
|
|
1147
1146
|
}
|
|
1148
1147
|
check_query_order(exchange) {
|
|
1149
|
-
|
|
1150
|
-
const QUERY_ORDER_TIME_IN_MS = 0
|
|
1148
|
+
const QUERY_ORDER_TIME_IN_MS = 30 * 60 * 1000
|
|
1149
|
+
// const QUERY_ORDER_TIME_IN_MS = 0
|
|
1151
1150
|
let query_order_handler = (exchange, pair, res) => {
|
|
1152
1151
|
if (res.success) {
|
|
1153
1152
|
_.set(this.query_order, [exchange, pair], { query_order: res.body, update_time: new Date() })
|
|
@@ -1172,6 +1171,7 @@ module.exports = class Orders {
|
|
|
1172
1171
|
let { open_time } = order_info[type][order_id]
|
|
1173
1172
|
// console.log(order_id, open_time, open_time < new Date() - 30 * 60 * 1000)
|
|
1174
1173
|
if (open_time < new Date() - QUERY_ORDER_TIME_IN_MS) {
|
|
1174
|
+
console.log('query_order_old_orders: %s %s %s', exchange, pair, order_id)
|
|
1175
1175
|
Exchanges[exchange].query_order(pair, order_id, (res) => {
|
|
1176
1176
|
count++
|
|
1177
1177
|
if (res.success) {
|