@icgio/icg-exchanges-wrapper 1.22.0 → 1.22.1
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 +26 -18
- package/package.json +1 -1
package/middleware/orders.js
CHANGED
|
@@ -524,24 +524,32 @@ module.exports = class Orders {
|
|
|
524
524
|
this.delete_order_info(exchange, pair, order.type, order.order_id, order.order_type + ' cancel-order-success')
|
|
525
525
|
}, this.delete_finished_orders_timeout)
|
|
526
526
|
} else if (!res.success && res.error === 'order-not-open' && original_status !== 'CANCELED') {
|
|
527
|
-
//
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
527
|
+
// Not-open ≠ filled: query the actual terminal state and book it via the standard
|
|
528
|
+
// reconciler. A failed query books CANCELED keeping known fills — never fabricate a fill.
|
|
529
|
+
this.Exchanges[exchange].query_order(pair, order.order_id, (query_res) => {
|
|
530
|
+
if (query_res.success) {
|
|
531
|
+
this.process_query_order({ [exchange]: { [pair]: { query_order: [query_res.body] } } })
|
|
532
|
+
return
|
|
533
|
+
}
|
|
534
|
+
console.error('cancel not-open, query_order failed: %s %s %s %j', exchange, pair, order.order_id, query_res)
|
|
535
|
+
this.update_order_info(
|
|
536
|
+
exchange,
|
|
537
|
+
pair,
|
|
538
|
+
order.type,
|
|
539
|
+
order.order_id,
|
|
540
|
+
{
|
|
541
|
+
status: 'CANCELED',
|
|
542
|
+
f_amount: order.f_amount || 0,
|
|
543
|
+
f_percentage: order.t_amount > 0 ? (order.f_amount || 0) / order.t_amount : 0,
|
|
544
|
+
close_time: Date.now(),
|
|
545
|
+
event_hrtime: process.hrtime(),
|
|
546
|
+
},
|
|
547
|
+
order.order_type + ' cannot-be-canceled query-failed',
|
|
548
|
+
)
|
|
549
|
+
setTimeout(() => {
|
|
550
|
+
this.delete_order_info(exchange, pair, order.type, order.order_id, order.order_type + ' cannot-be-canceled query-failed')
|
|
551
|
+
}, this.delete_finished_orders_timeout)
|
|
552
|
+
})
|
|
545
553
|
} else {
|
|
546
554
|
console.error('cancel order:', exchange, pair, order, res)
|
|
547
555
|
}
|