@icgio/icg-exchanges-wrapper 1.14.181 → 1.14.183
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 +89 -91
- package/package.json +3 -3
package/middleware/orders.js
CHANGED
|
@@ -480,97 +480,95 @@ module.exports = class Orders {
|
|
|
480
480
|
for (let exchange in trades) {
|
|
481
481
|
for (let pair in trades[exchange]) {
|
|
482
482
|
trades[exchange][pair].trades.map((trade) => {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
)
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
)
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
console.log('TRADES: UNKNOWN %j %j', order_info, trade)
|
|
573
|
-
}
|
|
483
|
+
trade.amount = round_amount(exchange, pair, trade.amount)
|
|
484
|
+
let { type, order_id } = trade
|
|
485
|
+
let order_info = _.get(this.order_info, [exchange, pair, type, order_id])
|
|
486
|
+
if (!order_info) {
|
|
487
|
+
} else if (_.includes(['CANCELED', 'CANCELING'], order_info.status) && trade.amount > order_info.f_amount) {
|
|
488
|
+
// console.log('TRADES: %s ORDER FILLED', order_info.status, trade, order_info)
|
|
489
|
+
this.update_order_info(
|
|
490
|
+
exchange,
|
|
491
|
+
pair,
|
|
492
|
+
type,
|
|
493
|
+
order_id,
|
|
494
|
+
{
|
|
495
|
+
// status: trade.amount / order_info.t_amount > this.f_filled_threshold ? 'F-FILLED' : 'P-FILLED', // could cause update undefined order error
|
|
496
|
+
price: trade.price,
|
|
497
|
+
amount: 0,
|
|
498
|
+
f_amount: trade.amount,
|
|
499
|
+
f_percentage: trade.amount / order_info.t_amount,
|
|
500
|
+
close_time: trade.close_time || new Date(),
|
|
501
|
+
fees: trade.fees,
|
|
502
|
+
},
|
|
503
|
+
order_info.order_type + ' canceled-order-filled(-more)'
|
|
504
|
+
)
|
|
505
|
+
setTimeout(() => {
|
|
506
|
+
this.delete_order_info(exchange, pair, type, order_id, order_info.order_type + ' canceled-order-filled(-more)')
|
|
507
|
+
}, this.delete_finished_orders_timeout)
|
|
508
|
+
} else if (order_info.status === 'F-FILLED' && trade.amount > order_info.f_amount) {
|
|
509
|
+
// console.log('TRADES: FILLED ORDER FILLED MORE', trade, order_info)
|
|
510
|
+
this.update_order_info(
|
|
511
|
+
exchange,
|
|
512
|
+
pair,
|
|
513
|
+
order_info.type,
|
|
514
|
+
order_info.order_id,
|
|
515
|
+
{
|
|
516
|
+
f_amount: trade.amount,
|
|
517
|
+
t_amount: trade.amount,
|
|
518
|
+
f_percentage: 1,
|
|
519
|
+
fees: trade.fees,
|
|
520
|
+
},
|
|
521
|
+
order_info.order_type + ' filled-order-filled-more'
|
|
522
|
+
)
|
|
523
|
+
} else if (
|
|
524
|
+
_.includes(['N-FILLED', 'P-FILLED'], order_info.status) &&
|
|
525
|
+
trade.amount > order_info.f_amount &&
|
|
526
|
+
trade.amount / order_info.t_amount > this.f_filled_threshold
|
|
527
|
+
) {
|
|
528
|
+
// console.log('TRADES: %s %s ORDER F-FILLED', exchange, pair, trade)
|
|
529
|
+
this.update_order_info(
|
|
530
|
+
exchange,
|
|
531
|
+
pair,
|
|
532
|
+
order_info.type,
|
|
533
|
+
order_info.order_id,
|
|
534
|
+
{
|
|
535
|
+
status: 'F-FILLED',
|
|
536
|
+
price: trade.price,
|
|
537
|
+
amount: order_info.t_amount - trade.amount,
|
|
538
|
+
f_amount: trade.amount,
|
|
539
|
+
f_percentage: trade.amount / order_info.t_amount,
|
|
540
|
+
close_time: trade.close_time || new Date(),
|
|
541
|
+
fees: trade.fees,
|
|
542
|
+
},
|
|
543
|
+
order_info.order_type + ' order-f-filled-1'
|
|
544
|
+
)
|
|
545
|
+
setTimeout(() => {
|
|
546
|
+
this.delete_order_info(exchange, pair, order_info.type, order_info.order_id, order_info.order_type + ' order-f-filled-1')
|
|
547
|
+
}, this.delete_finished_orders_timeout)
|
|
548
|
+
} else if (
|
|
549
|
+
_.includes(['N-FILLED', 'P-FILLED'], order_info.status) &&
|
|
550
|
+
trade.amount > order_info.f_amount &&
|
|
551
|
+
trade.amount / order_info.t_amount > this.p_filled_threshold
|
|
552
|
+
) {
|
|
553
|
+
// console.log('TRADES: %s %s ORDER P-FILLED', exchange, pair, trade)
|
|
554
|
+
this.update_order_info(
|
|
555
|
+
exchange,
|
|
556
|
+
pair,
|
|
557
|
+
order_info.type,
|
|
558
|
+
order_info.order_id,
|
|
559
|
+
{
|
|
560
|
+
status: 'P-FILLED',
|
|
561
|
+
amount: order_info.t_amount - trade.amount,
|
|
562
|
+
f_amount: trade.amount,
|
|
563
|
+
f_percentage: trade.amount / order_info.t_amount,
|
|
564
|
+
fees: trade.fees,
|
|
565
|
+
},
|
|
566
|
+
order_info.order_type + ' order-p-filled-1'
|
|
567
|
+
)
|
|
568
|
+
} else if (_.includes(['F-FILLED', 'P-FILLED'], order_info.status)) {
|
|
569
|
+
} else if (_.includes(['CANCELED', 'CANCELING'], order_info.status) && trade.amount === order_info.f_amount) {
|
|
570
|
+
} else {
|
|
571
|
+
console.log('TRADES: UNKNOWN %j %j', order_info, trade)
|
|
574
572
|
}
|
|
575
573
|
})
|
|
576
574
|
}
|
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.183",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@icgio/icg-exchanges": "^1.32.
|
|
21
|
-
"@icgio/icg-exchanges-data": "^1.10.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.32.90",
|
|
21
|
+
"@icgio/icg-exchanges-data": "^1.10.88",
|
|
22
22
|
"@icgio/icg-utils": "^1.9.30",
|
|
23
23
|
"influx": "^5.11.0",
|
|
24
24
|
"lodash": "^4.17.20",
|