@icgio/icg-exchanges-wrapper 1.14.249 → 1.14.251
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 +19 -15
- package/package.json +2 -2
package/middleware/orders.js
CHANGED
|
@@ -500,8 +500,10 @@ module.exports = class Orders {
|
|
|
500
500
|
trade.amount = round_amount(exchange, pair, trade.amount)
|
|
501
501
|
let { type, order_id } = trade
|
|
502
502
|
let order_info = _.get(this.order_info, [exchange, pair, type, order_id])
|
|
503
|
+
const trade_amount = round_amount(exchange, pair, trade.amount)
|
|
504
|
+
const order_info_f_amount = round_amount(exchange, pair, order_info.f_amount)
|
|
503
505
|
if (!order_info) {
|
|
504
|
-
} else if (_.includes(['CANCELED', 'CANCELING'], order_info.status) &&
|
|
506
|
+
} else if (_.includes(['CANCELED', 'CANCELING'], order_info.status) && trade_amount > order_info_f_amount) {
|
|
505
507
|
// console.log('TRADES: %s ORDER FILLED', order_info.status, trade, order_info)
|
|
506
508
|
this.update_order_info(
|
|
507
509
|
exchange,
|
|
@@ -512,8 +514,8 @@ module.exports = class Orders {
|
|
|
512
514
|
// status: trade.amount / order_info.t_amount > this.f_filled_threshold ? 'F-FILLED' : 'P-FILLED', // could cause update undefined order error
|
|
513
515
|
price: trade.price,
|
|
514
516
|
amount: 0,
|
|
515
|
-
f_amount:
|
|
516
|
-
f_percentage:
|
|
517
|
+
f_amount: trade_amount,
|
|
518
|
+
f_percentage: trade_amount / order_info.t_amount,
|
|
517
519
|
close_time: trade.close_time || new Date(),
|
|
518
520
|
fees: trade.fees,
|
|
519
521
|
},
|
|
@@ -522,7 +524,7 @@ module.exports = class Orders {
|
|
|
522
524
|
setTimeout(() => {
|
|
523
525
|
this.delete_order_info(exchange, pair, type, order_id, order_info.order_type + ' canceled-order-filled(-more)')
|
|
524
526
|
}, this.delete_finished_orders_timeout)
|
|
525
|
-
} else if (order_info.status === 'F-FILLED' &&
|
|
527
|
+
} else if (order_info.status === 'F-FILLED' && trade_amount > order_info_f_amount) {
|
|
526
528
|
// console.log('TRADES: FILLED ORDER FILLED MORE', trade, order_info)
|
|
527
529
|
this.update_order_info(
|
|
528
530
|
exchange,
|
|
@@ -530,7 +532,7 @@ module.exports = class Orders {
|
|
|
530
532
|
order_info.type,
|
|
531
533
|
order_info.order_id,
|
|
532
534
|
{
|
|
533
|
-
f_amount:
|
|
535
|
+
f_amount: trade_amount,
|
|
534
536
|
t_amount: trade.amount,
|
|
535
537
|
f_percentage: 1,
|
|
536
538
|
fees: trade.fees,
|
|
@@ -539,7 +541,7 @@ module.exports = class Orders {
|
|
|
539
541
|
)
|
|
540
542
|
} else if (
|
|
541
543
|
_.includes(['N-FILLED', 'P-FILLED'], order_info.status) &&
|
|
542
|
-
|
|
544
|
+
trade_amount > order_info_f_amount &&
|
|
543
545
|
trade.amount / order_info.t_amount > this.f_filled_threshold
|
|
544
546
|
) {
|
|
545
547
|
// console.log('TRADES: %s %s ORDER F-FILLED', exchange, pair, trade)
|
|
@@ -551,9 +553,9 @@ module.exports = class Orders {
|
|
|
551
553
|
{
|
|
552
554
|
status: 'F-FILLED',
|
|
553
555
|
price: trade.price,
|
|
554
|
-
amount: order_info.t_amount -
|
|
556
|
+
amount: order_info.t_amount - trade_amount,
|
|
555
557
|
f_amount: trade.amount,
|
|
556
|
-
f_percentage:
|
|
558
|
+
f_percentage: trade_amount / order_info.t_amount,
|
|
557
559
|
close_time: trade.close_time || new Date(),
|
|
558
560
|
fees: trade.fees,
|
|
559
561
|
},
|
|
@@ -658,7 +660,9 @@ module.exports = class Orders {
|
|
|
658
660
|
open_orders[exchange][pair].open_orders.map((order) => {
|
|
659
661
|
if (_.get(this.order_info, [exchange, pair, order.type, order.order_id])) {
|
|
660
662
|
let order_info = this.order_info[exchange][pair][order.type][order.order_id]
|
|
661
|
-
|
|
663
|
+
const order_f_amount = round_amount(exchange, pair, order.f_amount)
|
|
664
|
+
const order_info_f_amount = round_amount(exchange, pair, order_info.f_amount)
|
|
665
|
+
if (_.includes(['N-FILLED', 'P-FILLED'], order_info.status) && order_f_amount > order_info_f_amount && order_f_amount / order_info.t_amount > this.f_filled_threshold) {
|
|
662
666
|
// console.log('ORDERS: %s %s ORDER F-FILLED', exchange, pair)
|
|
663
667
|
this.update_order_info(
|
|
664
668
|
exchange,
|
|
@@ -668,8 +672,8 @@ module.exports = class Orders {
|
|
|
668
672
|
{
|
|
669
673
|
status: 'F-FILLED',
|
|
670
674
|
amount: order.amount,
|
|
671
|
-
f_amount:
|
|
672
|
-
f_percentage:
|
|
675
|
+
f_amount: order_f_amount,
|
|
676
|
+
f_percentage: order_f_amount / order_info.t_amount,
|
|
673
677
|
close_time: order.close_time || new Date(),
|
|
674
678
|
},
|
|
675
679
|
order_info.order_type + ' order-f-filled-3'
|
|
@@ -679,8 +683,8 @@ module.exports = class Orders {
|
|
|
679
683
|
}, this.delete_finished_orders_timeout)
|
|
680
684
|
} else if (
|
|
681
685
|
_.includes(['N-FILLED', 'P-FILLED'], order_info.status) &&
|
|
682
|
-
|
|
683
|
-
|
|
686
|
+
order_f_amount > order_info_f_amount &&
|
|
687
|
+
order_f_amount / order_info.t_amount > this.p_filled_threshold
|
|
684
688
|
) {
|
|
685
689
|
// console.log('ORDERS: %s %s ORDER P-FILLED', exchange, pair)
|
|
686
690
|
this.update_order_info(
|
|
@@ -691,8 +695,8 @@ module.exports = class Orders {
|
|
|
691
695
|
{
|
|
692
696
|
status: 'P-FILLED',
|
|
693
697
|
amount: order.amount,
|
|
694
|
-
f_amount:
|
|
695
|
-
f_percentage:
|
|
698
|
+
f_amount: order_f_amount,
|
|
699
|
+
f_percentage: order_f_amount / order_info.t_amount,
|
|
696
700
|
},
|
|
697
701
|
order_info.order_type + ' order-p-filled-2'
|
|
698
702
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-exchanges-wrapper",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.251",
|
|
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.32.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.32.136",
|
|
21
21
|
"@icgio/icg-utils": "^1.9.41",
|
|
22
22
|
"lodash": "^4.17.20",
|
|
23
23
|
"pg": "^8.13.1"
|