@icgio/icg-exchanges-wrapper 1.9.16 → 1.9.18
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 +13 -12
- package/package.json +3 -3
package/middleware/orders.js
CHANGED
|
@@ -50,6 +50,7 @@ module.exports = class Orders {
|
|
|
50
50
|
this.delete_finished_orders_timeout = settings.delete_finished_orders_timeout || 30 * 1000 // CANCELED or F-FILLED
|
|
51
51
|
this.interval_dict = settings.interval_dict || {}
|
|
52
52
|
this.major_exchanges = settings.major_exchanges || []
|
|
53
|
+
this.no_cancel_previous_exchanges = settings.no_cancel_previous_exchanges || []
|
|
53
54
|
this.no_cancel_range_exchanges = settings.no_cancel_range_exchanges || []
|
|
54
55
|
this.no_trades_function_exchanges = settings.no_trades_function_exchanges || []
|
|
55
56
|
this.no_trades_function_f_filled_timeout = settings.no_trades_function_f_filled_timeout || 30 * 1000
|
|
@@ -400,7 +401,7 @@ module.exports = class Orders {
|
|
|
400
401
|
for (let type in _.get(this.order_info, [exchange, pair], {})) {
|
|
401
402
|
for (let order_id in _.get(this.order_info, [exchange, pair, type], {})) {
|
|
402
403
|
let order_info_order = this.order_info[exchange][pair][type][order_id]
|
|
403
|
-
if ((order_info_order.status === 'N-FILLED' || order_info_order.status === 'P-FILLED') && order_info_order.open_time < new Date() - this.no_trades_function_f_filled_timeout) {
|
|
404
|
+
if ((order_info_order.status === 'N-FILLED' || order_info_order.status === 'P-FILLED') && order_info_order.open_time < new Date().getTime() - this.no_trades_function_f_filled_timeout) {
|
|
404
405
|
let exist = false
|
|
405
406
|
open_orders[exchange][pair].open_orders.map(o => {
|
|
406
407
|
if (o.order_id === order_info_order.order_id) {
|
|
@@ -516,7 +517,7 @@ module.exports = class Orders {
|
|
|
516
517
|
this.account_init = true
|
|
517
518
|
this.init_account(this.balances)
|
|
518
519
|
}
|
|
519
|
-
} else if (_.get(this.balances, [exchange, 'update_time']) < new Date() - this.interval_dict[exchange].balances) {
|
|
520
|
+
} else if (_.get(this.balances, [exchange, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].balances) {
|
|
520
521
|
this.info_log('%s balances expired: %j', exchange, res)
|
|
521
522
|
this.balances = _.omit(this.balances, [exchange])
|
|
522
523
|
this.buy_sell_limits = _.omit(this.buy_sell_limits, [exchange])
|
|
@@ -554,7 +555,7 @@ module.exports = class Orders {
|
|
|
554
555
|
})
|
|
555
556
|
})
|
|
556
557
|
}
|
|
557
|
-
} else if (_.get(this.positions, [exchange, 'update_time']) < new Date() - this.interval_dict[exchange].positions) {
|
|
558
|
+
} else if (_.get(this.positions, [exchange, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].positions) {
|
|
558
559
|
this.info_log('%s positions expired: %j', exchange, res)
|
|
559
560
|
this.positions = _.omit(this.positions, [exchange])
|
|
560
561
|
this.buy_sell_limits = _.omit(this.buy_sell_limits, [exchange])
|
|
@@ -594,7 +595,7 @@ module.exports = class Orders {
|
|
|
594
595
|
check_open_orders () {
|
|
595
596
|
const open_orders_timeframe = 12 * 60 * 60 * 1000
|
|
596
597
|
let previous_orders_processer = (exchange, pair, orders) => {
|
|
597
|
-
if (this.cancel_previous_orders && !this.previous_orders_canceled) {
|
|
598
|
+
if (this.cancel_previous_orders && !this.previous_orders_canceled && this.no_cancel_previous_exchanges.indexOf(exchange) === -1) {
|
|
598
599
|
orders.map(order => {
|
|
599
600
|
this.info_log('cancel original order: %s %s %j', exchange, pair, order)
|
|
600
601
|
this.Exchanges[exchange].cancel_order_by_order(order, (res) => {})
|
|
@@ -637,7 +638,7 @@ module.exports = class Orders {
|
|
|
637
638
|
if (res.success) {
|
|
638
639
|
_.set(this.open_orders, [exchange, pair], { open_orders: res.body, update_time: new Date() })
|
|
639
640
|
previous_orders_processer(exchange, pair, res.body)
|
|
640
|
-
} else if (_.get(this.open_orders, [exchange, pair, 'update_time']) < new Date() - this.interval_dict[exchange].open_orders) {
|
|
641
|
+
} else if (_.get(this.open_orders, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].open_orders) {
|
|
641
642
|
this.info_log('%s %s open orders expired: %j', exchange, pair, res)
|
|
642
643
|
this.open_orders[exchange] = _.omit(this.open_orders[exchange], [pair])
|
|
643
644
|
} else if (res.error !== 'opening') {
|
|
@@ -654,7 +655,7 @@ module.exports = class Orders {
|
|
|
654
655
|
} else {
|
|
655
656
|
let error_logged = false
|
|
656
657
|
for (let pair of this.exchange_pairs[exchange]) {
|
|
657
|
-
if (_.get(this.open_orders, [exchange, pair, 'update_time']) < new Date() - this.interval_dict[exchange].open_orders) {
|
|
658
|
+
if (_.get(this.open_orders, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].open_orders) {
|
|
658
659
|
if (!error_logged) {
|
|
659
660
|
this.info_log('%s all open orders expired: %j', exchange, res)
|
|
660
661
|
error_logged = true
|
|
@@ -729,8 +730,8 @@ module.exports = class Orders {
|
|
|
729
730
|
let trades_handler = (exchange, pair, res) => {
|
|
730
731
|
if (res.success) {
|
|
731
732
|
_.set(this.trades, [exchange, pair], { trades: res.body, update_time: new Date() })
|
|
732
|
-
_.set(this.trades_amount_past_hour, [exchange, pair], _.sumBy(res.body.filter(t => t.close_time > new Date() - 60 * 60 * 1000 || t.open_time > new Date() - 60 * 60 * 1000), t => t.amount) || 0)
|
|
733
|
-
} else if (_.get(this.trades, [exchange, pair, 'update_time']) < new Date() - this.interval_dict[exchange].trades) {
|
|
733
|
+
_.set(this.trades_amount_past_hour, [exchange, pair], _.sumBy(res.body.filter(t => t.close_time > new Date().getTime() - 60 * 60 * 1000 || t.open_time > new Date().getTime() - 60 * 60 * 1000), t => t.amount) || 0)
|
|
734
|
+
} else if (_.get(this.trades, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].trades) {
|
|
734
735
|
this.info_log('%s %s trades expired: %j', exchange, pair, res)
|
|
735
736
|
this.trades[exchange] = _.omit(this.trades[exchange], [pair])
|
|
736
737
|
} else if (res.error !== 'opening') {
|
|
@@ -742,12 +743,12 @@ module.exports = class Orders {
|
|
|
742
743
|
for (let pair of this.exchange_pairs[exchange]) {
|
|
743
744
|
let trades = res.body.filter(o => o.pair === pair)
|
|
744
745
|
_.set(this.trades, [exchange, pair], { trades: trades, update_time: new Date() })
|
|
745
|
-
_.set(this.trades_amount_past_hour, [exchange, pair], _.sumBy(trades.filter(t => t.close_time > new Date() - 60 * 60 * 1000 || t.open_time > new Date() - 60 * 60 * 1000), t => t.amount) || 0)
|
|
746
|
+
_.set(this.trades_amount_past_hour, [exchange, pair], _.sumBy(trades.filter(t => t.close_time > new Date().getTime() - 60 * 60 * 1000 || t.open_time > new Date().getTime() - 60 * 60 * 1000), t => t.amount) || 0)
|
|
746
747
|
}
|
|
747
748
|
} else if (res.error !== 'opening') {
|
|
748
749
|
let error_logged = false
|
|
749
750
|
for (let pair of this.exchange_pairs[exchange]) {
|
|
750
|
-
if (_.get(this.trades, [exchange, pair, 'update_time']) < new Date() - this.interval_dict[exchange].trades) {
|
|
751
|
+
if (_.get(this.trades, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].trades) {
|
|
751
752
|
if (!error_logged) {
|
|
752
753
|
this.info_log('%s all trades expired: %j', exchange, res)
|
|
753
754
|
error_logged = true
|
|
@@ -929,7 +930,7 @@ module.exports = class Orders {
|
|
|
929
930
|
}
|
|
930
931
|
}
|
|
931
932
|
}
|
|
932
|
-
} else if (_.get(this.rates, [exchange, pair, 'update_time']) < new Date() - this.interval_dict[exchange].rates) {
|
|
933
|
+
} else if (_.get(this.rates, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].rates) {
|
|
933
934
|
this.info_log('%s %s rates expired: %j', exchange, pair, res)
|
|
934
935
|
this.rates[exchange] = _.omit(this.rates[exchange], [pair])
|
|
935
936
|
}
|
|
@@ -962,7 +963,7 @@ module.exports = class Orders {
|
|
|
962
963
|
let market_history_handler = (exchange, pair, res) => {
|
|
963
964
|
if (res.success) {
|
|
964
965
|
_.set(this.market_history, [exchange, pair], Object.assign(res.body, { update_time: new Date() }))
|
|
965
|
-
} else if (_.get(this.market_history, [exchange, pair, 'update_time']) < new Date() - this.interval_dict[exchange].market_history) {
|
|
966
|
+
} else if (_.get(this.market_history, [exchange, pair, 'update_time']) < new Date().getTime() - this.interval_dict[exchange].market_history) {
|
|
966
967
|
this.info_log('%s %s market_history expired: %j', exchange, pair, res)
|
|
967
968
|
this.market_history[exchange] = _.omit(this.market_history[exchange], [pair])
|
|
968
969
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-exchanges-wrapper",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@icgio/icg-exchanges": "^1.27.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.27.9",
|
|
21
21
|
"@icgio/icg-exchanges-data": "^1.6.8",
|
|
22
|
-
"@icgio/icg-utils": "^1.7.
|
|
22
|
+
"@icgio/icg-utils": "^1.7.4",
|
|
23
23
|
"influx": "^5.7.0",
|
|
24
24
|
"lodash": "^4.17.20",
|
|
25
25
|
"needle": "^2.6.0",
|