@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.
@@ -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
- // console.log('%s ORDER CANNOT BE CANCELED: %j', original_status, order)
528
- this.update_order_info(
529
- exchange,
530
- pair,
531
- order.type,
532
- order.order_id,
533
- {
534
- status: 'F-FILLED',
535
- amount: 0,
536
- f_amount: order.amount,
537
- f_percentage: 1,
538
- close_time: Date.now(),
539
- },
540
- order.order_type + ' cannot-be-canceled',
541
- )
542
- setTimeout(() => {
543
- this.delete_order_info(exchange, pair, order.type, order.order_id, order.order_type + ' cannot-be-canceled')
544
- }, this.delete_finished_orders_timeout)
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-exchanges-wrapper",
3
- "version": "1.22.0",
3
+ "version": "1.22.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {