@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.
@@ -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
- if (_.get(this.order_info, [exchange, pair, trade.type, trade.order_id])) {
484
- let order_info = this.order_info[exchange][pair][trade.type][trade.order_id]
485
- trade.amount = round_amount(exchange, pair, trade.amount)
486
- if (_.includes(['CANCELED', 'CANCELING'], order_info.status) && trade.amount > order_info.f_amount) {
487
- let type = trade.type,
488
- order_id = trade.order_id
489
- // console.log('TRADES: %s ORDER FILLED', order_info.status, trade, order_info)
490
- this.update_order_info(
491
- exchange,
492
- pair,
493
- type,
494
- order_id,
495
- {
496
- status: trade.amount / order_info.t_amount > this.f_filled_threshold ? 'F-FILLED' : 'P-FILLED',
497
- price: trade.price,
498
- amount: 0,
499
- f_amount: trade.amount,
500
- f_percentage: trade.amount / order_info.t_amount,
501
- close_time: trade.close_time || new Date(),
502
- fees: trade.fees,
503
- },
504
- order_info.order_type + ' canceled-order-filled(-more)'
505
- )
506
- setTimeout(() => {
507
- this.delete_order_info(exchange, pair, type, order_id, order_info.order_type + ' canceled-order-filled(-more)')
508
- }, this.delete_finished_orders_timeout)
509
- } else if (order_info.status === 'F-FILLED' && trade.amount > order_info.f_amount) {
510
- // console.log('TRADES: FILLED ORDER FILLED MORE', trade, order_info)
511
- this.update_order_info(
512
- exchange,
513
- pair,
514
- order_info.type,
515
- order_info.order_id,
516
- {
517
- f_amount: trade.amount,
518
- t_amount: trade.amount,
519
- f_percentage: 1,
520
- fees: trade.fees,
521
- },
522
- order_info.order_type + ' filled-order-filled-more'
523
- )
524
- } else if (
525
- _.includes(['N-FILLED', 'P-FILLED'], order_info.status) &&
526
- trade.amount > order_info.f_amount &&
527
- trade.amount / order_info.t_amount > this.f_filled_threshold
528
- ) {
529
- // console.log('TRADES: %s %s ORDER F-FILLED', exchange, pair, trade)
530
- this.update_order_info(
531
- exchange,
532
- pair,
533
- order_info.type,
534
- order_info.order_id,
535
- {
536
- status: 'F-FILLED',
537
- price: trade.price,
538
- amount: order_info.t_amount - trade.amount,
539
- f_amount: trade.amount,
540
- f_percentage: trade.amount / order_info.t_amount,
541
- close_time: trade.close_time || new Date(),
542
- fees: trade.fees,
543
- },
544
- order_info.order_type + ' order-f-filled-1'
545
- )
546
- setTimeout(() => {
547
- this.delete_order_info(exchange, pair, order_info.type, order_info.order_id, order_info.order_type + ' order-f-filled-1')
548
- }, this.delete_finished_orders_timeout)
549
- } else if (
550
- _.includes(['N-FILLED', 'P-FILLED'], order_info.status) &&
551
- trade.amount > order_info.f_amount &&
552
- trade.amount / order_info.t_amount > this.p_filled_threshold
553
- ) {
554
- // console.log('TRADES: %s %s ORDER P-FILLED', exchange, pair, trade)
555
- this.update_order_info(
556
- exchange,
557
- pair,
558
- order_info.type,
559
- order_info.order_id,
560
- {
561
- status: 'P-FILLED',
562
- amount: order_info.t_amount - trade.amount,
563
- f_amount: trade.amount,
564
- f_percentage: trade.amount / order_info.t_amount,
565
- fees: trade.fees,
566
- },
567
- order_info.order_type + ' order-p-filled-1'
568
- )
569
- } else if (_.includes(['F-FILLED', 'P-FILLED'], order_info.status)) {
570
- } else if (_.includes(['CANCELED', 'CANCELING'], order_info.status) && trade.amount === order_info.f_amount) {
571
- } else {
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.181",
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.89",
21
- "@icgio/icg-exchanges-data": "^1.10.87",
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",