@icgio/icg-exchanges-wrapper 1.14.25 → 1.14.26
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/functions/get-exchanges-balance.js +29 -25
- package/functions/get-exchanges-deposits.js +5 -1
- package/functions/get-exchanges-open-orders.js +5 -1
- package/functions/get-exchanges-rates-market-history-ohlcv.js +9 -3
- package/functions/get-exchanges-trades.js +5 -1
- package/functions/get-exchanges-withdrawals.js +5 -1
- package/package.json +1 -1
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
const _ = require('lodash')
|
|
1
|
+
const _ = require('lodash')
|
|
2
2
|
let balances = {}
|
|
3
|
-
|
|
3
|
+
const get_exchanges_balance = function (exchanges, cb) {
|
|
4
4
|
if (!Array.isArray(exchanges)) {
|
|
5
|
-
console.error('exchanges should be an array')
|
|
6
|
-
return
|
|
5
|
+
console.error('exchanges should be an array')
|
|
6
|
+
return
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const promises = exchanges.map(exchange => {
|
|
9
|
+
const promises = exchanges.map((exchange) => {
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
11
|
if (exchange.balance_ws) {
|
|
12
|
-
if (exchange.ws_status().trading === 'n-opened') exchange.ws_account()
|
|
12
|
+
if (exchange.ws_status().trading === 'n-opened') exchange.ws_account()
|
|
13
13
|
exchange.balance_ws(function (res) {
|
|
14
14
|
if (res.success) {
|
|
15
|
-
_.set(balances, exchange.settings.id, res.body)
|
|
16
|
-
resolve()
|
|
15
|
+
_.set(balances, exchange.settings.id, res.body)
|
|
16
|
+
resolve()
|
|
17
17
|
} else {
|
|
18
|
-
delete balances[exchange.name]
|
|
19
|
-
resolve()
|
|
18
|
+
delete balances[exchange.name]
|
|
19
|
+
resolve()
|
|
20
20
|
}
|
|
21
|
-
})
|
|
21
|
+
})
|
|
22
22
|
} else if (exchange.balance) {
|
|
23
23
|
exchange.balance(function (res) {
|
|
24
24
|
if (res.success) {
|
|
25
|
-
_.set(balances, exchange.settings.id, res.body)
|
|
26
|
-
resolve()
|
|
25
|
+
_.set(balances, exchange.settings.id, res.body)
|
|
26
|
+
resolve()
|
|
27
27
|
} else {
|
|
28
|
-
delete balances[exchange.name]
|
|
29
|
-
resolve()
|
|
28
|
+
delete balances[exchange.name]
|
|
29
|
+
resolve()
|
|
30
30
|
}
|
|
31
|
-
})
|
|
31
|
+
})
|
|
32
32
|
} else {
|
|
33
|
-
resolve()
|
|
33
|
+
resolve()
|
|
34
34
|
}
|
|
35
|
-
})
|
|
36
|
-
})
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
37
|
|
|
38
38
|
Promise.all(promises)
|
|
39
39
|
.then(() => {
|
|
40
|
-
cb(balances)
|
|
40
|
+
cb(balances)
|
|
41
|
+
})
|
|
42
|
+
.catch((error) => {
|
|
43
|
+
console.error('Error fetching balances:', error)
|
|
44
|
+
cb({})
|
|
41
45
|
})
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
get_exchanges_balance,
|
|
50
|
+
}
|
|
@@ -5,7 +5,7 @@ const INVALID_EXCHANGES_LIST = ['Bitforex', 'Thinkbit', 'Kkcoin']
|
|
|
5
5
|
let exchange_pair_deposits = {}
|
|
6
6
|
let deposits_status = {}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function get_exchanges_deposits(exchanges, client_currency, cb) {
|
|
9
9
|
if (!Array.isArray(exchanges)) {
|
|
10
10
|
console.error('exchanges should be an array')
|
|
11
11
|
return
|
|
@@ -77,3 +77,7 @@ module.exports = function (exchanges, client_currency, cb) {
|
|
|
77
77
|
cb({})
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
get_exchanges_deposits,
|
|
83
|
+
}
|
|
@@ -5,7 +5,7 @@ const INVALID_EXCHANGES_LIST = ['Bitforex', 'Thinkbit', 'Kkcoin']
|
|
|
5
5
|
let exchange_pair_open_orders = {}
|
|
6
6
|
let open_orders_status = {}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const get_exchanges_open_orders = function (exchanges, exchange_pair_dict, cb, ws_enabled = true) {
|
|
9
9
|
if (!Array.isArray(exchanges)) {
|
|
10
10
|
console.error('exchanges should be an array')
|
|
11
11
|
return
|
|
@@ -90,3 +90,7 @@ module.exports = function (exchanges, exchange_pair_dict, cb, ws_enabled = true)
|
|
|
90
90
|
cb({})
|
|
91
91
|
})
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
get_exchanges_open_orders,
|
|
96
|
+
}
|
|
@@ -6,7 +6,7 @@ let first_time = {},
|
|
|
6
6
|
exchange_pair_rates = {},
|
|
7
7
|
pair_exchange_rates = {}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enabled = true) {
|
|
10
10
|
let checked_rates = {}
|
|
11
11
|
let promises = []
|
|
12
12
|
|
|
@@ -137,7 +137,7 @@ module.exports.get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb
|
|
|
137
137
|
let checked_market_history = {},
|
|
138
138
|
exchange_pair_market_history = {},
|
|
139
139
|
pair_exchange_market_history = {}
|
|
140
|
-
|
|
140
|
+
const get_exchanges_market_history = function (Exchanges, exchange_pair_dict, timeframe_in_ms, cb, ws_enabled = true) {
|
|
141
141
|
checked_market_history = {}
|
|
142
142
|
if (!Array.isArray(Exchanges)) {
|
|
143
143
|
console.error('Exchanges should be an array')
|
|
@@ -199,7 +199,7 @@ let checked_ohlcv_exchange = {},
|
|
|
199
199
|
ohlcv_status = {},
|
|
200
200
|
exchange_pair_ohlcv = {},
|
|
201
201
|
pair_exchange_ohlcv = {}
|
|
202
|
-
|
|
202
|
+
const get_exchanges_ohlcv = function (Exchanges, exchange_pair_dict, from_in_ms, to_in_ms, cb) {
|
|
203
203
|
checked_ohlcv_exchange = {}
|
|
204
204
|
if (!Array.isArray(Exchanges)) {
|
|
205
205
|
console.error('Exchanges should be an array')
|
|
@@ -244,3 +244,9 @@ module.exports.get_exchanges_ohlcv = function (Exchanges, exchange_pair_dict, fr
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
+
|
|
248
|
+
module.exports = {
|
|
249
|
+
get_exchanges_rates,
|
|
250
|
+
get_exchanges_market_history,
|
|
251
|
+
get_exchanges_ohlcv,
|
|
252
|
+
}
|
|
@@ -6,7 +6,7 @@ const TRADES_TIMEFRAME = 1000000 * 60 * 1000
|
|
|
6
6
|
let exchange_pair_trades = {}
|
|
7
7
|
let trades_status = {}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const get_exchanges_trades = function (exchanges, exchange_pair_dict, cb, ws_enabled = true) {
|
|
10
10
|
if (!Array.isArray(exchanges)) {
|
|
11
11
|
console.error('exchanges should be an array')
|
|
12
12
|
return
|
|
@@ -138,3 +138,7 @@ module.exports = function (exchanges, exchange_pair_dict, cb, ws_enabled = true)
|
|
|
138
138
|
cb({})
|
|
139
139
|
})
|
|
140
140
|
}
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
get_exchanges_trades,
|
|
144
|
+
}
|
|
@@ -5,7 +5,7 @@ const INVALID_EXCHANGES_LIST = ['Bitforex', 'Thinkbit', 'Kkcoin']
|
|
|
5
5
|
let exchange_pair_withdrawals = {}
|
|
6
6
|
let withdrawals_status = {}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const get_exchanges_withdrawals = function (exchanges, client_currency, cb) {
|
|
9
9
|
if (!Array.isArray(exchanges)) {
|
|
10
10
|
console.error('exchanges should be an array')
|
|
11
11
|
return
|
|
@@ -77,3 +77,7 @@ module.exports = function (exchanges, client_currency, cb) {
|
|
|
77
77
|
cb({})
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
get_exchanges_withdrawals,
|
|
83
|
+
}
|