@icgio/icg-exchanges-wrapper 1.22.1 → 1.22.2
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 +24 -14
- package/package.json +1 -1
package/middleware/orders.js
CHANGED
|
@@ -954,24 +954,34 @@ module.exports = class Orders {
|
|
|
954
954
|
}
|
|
955
955
|
})
|
|
956
956
|
|
|
957
|
-
// If CANCELING orders are no longer in open_orders, infer they are canceled
|
|
957
|
+
// If CANCELING orders are no longer in open_orders, infer they are canceled — unless
|
|
958
|
+
// trades already show the order effectively filled: absence from the book is no
|
|
959
|
+
// evidence of cancellation for a filled order (push-tier races made that booking
|
|
960
|
+
// ping-pong CANCELED -> F-FILLED through the query reconciler ~1/min on busy venues).
|
|
958
961
|
const open_orders_ids_set = new Set(open_orders[exchange][pair].open_orders.map((o) => o.order_id))
|
|
959
962
|
this.get_order_info_status_all(exchange, pair, 'both', 'CANCELING').map((order_info) => {
|
|
960
963
|
if (order_info.order_id && !open_orders_ids_set.has(order_info.order_id)) {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
{
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
964
|
+
const swept_f_amount = round_amount(exchange, pair, order_info.f_amount || 0)
|
|
965
|
+
const swept_t_amount = round_amount(exchange, pair, order_info.t_amount || 0)
|
|
966
|
+
const effectively_filled = swept_t_amount > 0 && swept_f_amount / swept_t_amount > this.f_filled_threshold
|
|
967
|
+
const note = (order_info.order_type || '') + (effectively_filled ? ' canceling-filled-from-open-orders' : ' canceling-canceled-from-open-orders')
|
|
968
|
+
const update_dict = effectively_filled
|
|
969
|
+
? {
|
|
970
|
+
status: 'F-FILLED',
|
|
971
|
+
amount: 0,
|
|
972
|
+
f_amount: swept_f_amount,
|
|
973
|
+
f_percentage: swept_f_amount / swept_t_amount,
|
|
974
|
+
close_time: Date.now(),
|
|
975
|
+
event_hrtime: process.hrtime(),
|
|
976
|
+
}
|
|
977
|
+
: {
|
|
978
|
+
status: 'CANCELED',
|
|
979
|
+
close_time: Date.now(),
|
|
980
|
+
event_hrtime: process.hrtime(),
|
|
981
|
+
}
|
|
982
|
+
this.update_order_info(exchange, pair, order_info.type, order_info.order_id, update_dict, note)
|
|
973
983
|
setTimeout(() => {
|
|
974
|
-
this.delete_order_info(exchange, pair, order_info.type, order_info.order_id,
|
|
984
|
+
this.delete_order_info(exchange, pair, order_info.type, order_info.order_id, note)
|
|
975
985
|
}, this.delete_finished_orders_timeout)
|
|
976
986
|
}
|
|
977
987
|
})
|