@icgio/icg-exchanges-wrapper 1.14.233 → 1.14.235
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 +14 -7
- package/package.json +1 -1
package/middleware/orders.js
CHANGED
|
@@ -44,9 +44,9 @@ const MINIMUM_LIMITS = {
|
|
|
44
44
|
private_interval_concurrent: 1000,
|
|
45
45
|
}
|
|
46
46
|
const HKBITEX_LIMITS = {
|
|
47
|
-
public_max_concurrent:
|
|
47
|
+
public_max_concurrent: 200,
|
|
48
48
|
public_interval_concurrent: 1000,
|
|
49
|
-
private_max_concurrent:
|
|
49
|
+
private_max_concurrent: 100,
|
|
50
50
|
private_interval_concurrent: 1000,
|
|
51
51
|
}
|
|
52
52
|
const SWFT_LIMITS = {
|
|
@@ -125,8 +125,6 @@ module.exports = class Orders {
|
|
|
125
125
|
this.accounting_benchmark = settings.accounting_benchmark
|
|
126
126
|
this.balance_benchmark = settings.balance_benchmark || {}
|
|
127
127
|
this.min_reserve_balance = settings.min_reserve_balance || {}
|
|
128
|
-
// Initialize all orders store for PostgreSQL persistence (async, non-blocking)
|
|
129
|
-
this.all_orders_store = new AllOrdersStore(cd.all_orders_store_connection_string)
|
|
130
128
|
for (let exchange in exchange_pairs) {
|
|
131
129
|
let api_key_temp = cd[exchange]['api_keys'] || cd[exchange]['api_key'],
|
|
132
130
|
secret_key_temp = cd[exchange]['secret_keys'] || cd[exchange]['secret_key'],
|
|
@@ -201,6 +199,7 @@ module.exports = class Orders {
|
|
|
201
199
|
market_history_check: true,
|
|
202
200
|
ohlcv_check: false,
|
|
203
201
|
cmc_rates_check: true,
|
|
202
|
+
all_orders_store: false,
|
|
204
203
|
}
|
|
205
204
|
if (this.function_enabled.balances_check) {
|
|
206
205
|
this.check_balances()
|
|
@@ -245,6 +244,10 @@ module.exports = class Orders {
|
|
|
245
244
|
this.process_query_order(this.query_order)
|
|
246
245
|
}, PROCESS_OPEN_ORDERS_TRADERS_INTERVAL_MS)
|
|
247
246
|
}
|
|
247
|
+
if (this.function_enabled.all_orders_store) {
|
|
248
|
+
// Initialize all orders store for PostgreSQL persistence (async, non-blocking)
|
|
249
|
+
this.all_orders_store = new AllOrdersStore(cd.all_orders_store_connection_string)
|
|
250
|
+
}
|
|
248
251
|
}
|
|
249
252
|
init_account(balances, benchmarks) {
|
|
250
253
|
this.account = new Account(balances, benchmarks)
|
|
@@ -758,7 +761,9 @@ module.exports = class Orders {
|
|
|
758
761
|
// end: log every f-filled trade for future analysis
|
|
759
762
|
// Store order status to PostgreSQL asynchronously (non-blocking)
|
|
760
763
|
const order_data = _.get(this.order_info, [exchange, pair, type, order_id], {})
|
|
761
|
-
this.all_orders_store
|
|
764
|
+
if (this.function_enabled.all_orders_store) {
|
|
765
|
+
this.all_orders_store.store(exchange, pair, type, order_id, order_data, note)
|
|
766
|
+
}
|
|
762
767
|
}
|
|
763
768
|
delete_order_info(exchange, pair, type, order_id, note) {
|
|
764
769
|
const order_data = _.get(this.order_info, [exchange, pair, type, order_id], {})
|
|
@@ -767,7 +772,7 @@ module.exports = class Orders {
|
|
|
767
772
|
// Store deletion to PostgreSQL (non-blocking)
|
|
768
773
|
// Keep final F-FILLED / P-FILLED states in DB (do NOT mark them as DELETED)
|
|
769
774
|
if (order_data.status === 'F-FILLED' || order_data.status === 'P-FILLED') {
|
|
770
|
-
} else {
|
|
775
|
+
} else if (this.function_enabled.all_orders_store) {
|
|
771
776
|
this.all_orders_store.store(exchange, pair, type, order_id, { ...order_data, status: 'DELETED' }, note)
|
|
772
777
|
}
|
|
773
778
|
}
|
|
@@ -891,7 +896,9 @@ module.exports = class Orders {
|
|
|
891
896
|
// cancel previous orders
|
|
892
897
|
else if (this.cancel_previous_orders && !this.previous_orders_canceled) {
|
|
893
898
|
// remove all previous orders for this exchange/pair from all_orders (fire-and-forget)
|
|
894
|
-
this.all_orders_store
|
|
899
|
+
if (this.function_enabled.all_orders_store) {
|
|
900
|
+
this.all_orders_store.clear_orders(exchange, pair).catch((err) => console.error('clear_all_orders error', exchange, pair, err.message))
|
|
901
|
+
}
|
|
895
902
|
if (this.cancel_previous_orders_with_delay) {
|
|
896
903
|
setTimeout(() => {
|
|
897
904
|
orders.map((order) => {
|