@icgio/icg-exchanges-wrapper 1.9.154 → 1.9.156
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.
|
@@ -125,26 +125,28 @@ module.exports.get_exchanges_market_history = function (Exchanges, exchange_pair
|
|
|
125
125
|
cb({ exchange_pair_market_history, pair_exchange_market_history })
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
let
|
|
128
|
+
let checked_ohlcv_exchange = {},
|
|
129
|
+
ohlcv_status = {},
|
|
129
130
|
exchange_pair_ohlcv = {},
|
|
130
131
|
pair_exchange_ohlcv = {}
|
|
131
132
|
module.exports.get_exchanges_ohlcv = function (Exchanges, exchange_pair_dict, from_in_ms, to_in_ms, cb) {
|
|
132
|
-
|
|
133
|
+
checked_ohlcv_exchange = {}
|
|
133
134
|
if (!Array.isArray(Exchanges)) {
|
|
134
135
|
console.error('Exchanges should be an array')
|
|
135
136
|
return
|
|
136
137
|
} else {
|
|
137
138
|
for (let Exchange of Exchanges) {
|
|
138
139
|
let Exchange_name = _.upperFirst(Exchange.name)
|
|
139
|
-
if (
|
|
140
|
+
if (checked_ohlcv_exchange[Exchange_name]) {
|
|
140
141
|
continue
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
+
checked_ohlcv_exchange[Exchange_name] = true
|
|
143
144
|
if (!exchange_pair_dict[Exchange_name]) {
|
|
144
145
|
continue
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
for (let pair of exchange_pair_dict[Exchange_name]) {
|
|
148
|
+
_.set(ohlcv_status, [exchange + pair], false)
|
|
149
|
+
if (Exchange.ohlcv) {
|
|
148
150
|
Exchange.ohlcv(pair, from_in_ms, to_in_ms, function (res) {
|
|
149
151
|
if (res.success) {
|
|
150
152
|
_.set(exchange_pair_ohlcv, [Exchange_name, pair], res.body)
|
|
@@ -157,10 +159,18 @@ module.exports.get_exchanges_ohlcv = function (Exchanges, exchange_pair_dict, fr
|
|
|
157
159
|
delete pair_exchange_ohlcv[pair][Exchange_name]
|
|
158
160
|
}
|
|
159
161
|
}
|
|
162
|
+
_.set(ohlcv_status, [exchange + pair], true)
|
|
163
|
+
if (!_.includes(_.values(ohlcv_status), false)) {
|
|
164
|
+
cb({ exchange_pair_ohlcv, pair_exchange_ohlcv })
|
|
165
|
+
}
|
|
160
166
|
})
|
|
167
|
+
} else {
|
|
168
|
+
_.set(ohlcv_status, [exchange + pair], true)
|
|
169
|
+
if (!_.includes(_.values(ohlcv_status), false)) {
|
|
170
|
+
cb({ exchange_pair_ohlcv, pair_exchange_ohlcv })
|
|
171
|
+
}
|
|
161
172
|
}
|
|
162
173
|
}
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
|
-
cb({ exchange_pair_ohlcv, pair_exchange_ohlcv })
|
|
166
176
|
}
|
|
@@ -3,32 +3,31 @@ const _ = require('lodash')
|
|
|
3
3
|
const INVALID_EXCHANGES_LIST = ['Bitforex', 'Thinkbit', 'Kkcoin']
|
|
4
4
|
const TRADES_TIMEFRAME = 10 * 60 * 1000
|
|
5
5
|
|
|
6
|
-
let first_time = {},
|
|
7
|
-
|
|
6
|
+
let first_time = {},
|
|
7
|
+
exchange_pair_trades = {},
|
|
8
|
+
trades_status = {}
|
|
9
|
+
module.exports.get_exchanges_trades = function (Exchanges, exchange_pair_dict, cb, ws_enabled = true) {
|
|
8
10
|
if (!Array.isArray(Exchanges)) {
|
|
9
11
|
console.error('Exchanges should be an array')
|
|
10
12
|
return
|
|
11
13
|
} else {
|
|
12
14
|
for (let exchange of Exchanges) {
|
|
13
|
-
let exchange_name = exchange.name,
|
|
15
|
+
let exchange_name = exchange.name,
|
|
16
|
+
exchange_id = exchange.exchange_id
|
|
14
17
|
if (!exchange_pair_dict[exchange_name]) {
|
|
15
18
|
continue
|
|
16
19
|
}
|
|
17
20
|
let pair_list = exchange_pair_dict[exchange_name]
|
|
18
21
|
for (let pair of pair_list) {
|
|
19
|
-
_.set(
|
|
22
|
+
_.set(trades_status, [exchange + pair], false)
|
|
20
23
|
}
|
|
21
24
|
if (_.includes(INVALID_EXCHANGES_LIST, exchange_name)) {
|
|
22
25
|
continue
|
|
23
26
|
} else if (exchange.get_all_trades_ws) {
|
|
24
|
-
if (exchange.
|
|
25
|
-
exchange.ws_account()
|
|
27
|
+
if (exchange.ws_trades_status().trading === 'n-opened') exchange.ws_account()
|
|
26
28
|
exchange.get_all_trades_ws(TRADES_TIMEFRAME, function (res) {
|
|
27
|
-
for (let pair of pair_list) {
|
|
28
|
-
_.set(status, [exchange + pair], true)
|
|
29
|
-
}
|
|
30
29
|
if (res.success) {
|
|
31
|
-
res.body(trade => {
|
|
30
|
+
res.body((trade) => {
|
|
32
31
|
let pair = trade.pair
|
|
33
32
|
if (!_.get(exchange_pair_trades, [exchange, pair])) {
|
|
34
33
|
_.set(exchange_pair_trades, [exchange_id, pair], [])
|
|
@@ -41,38 +40,39 @@ module.exports.get_exchanges_trades = function (Exchanges, exchange_pair_dict, c
|
|
|
41
40
|
delete exchange_pair_trades[exchange]
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
for (let pair of pair_list) {
|
|
44
|
+
_.set(trades_status, [exchange + pair], true)
|
|
45
|
+
}
|
|
46
|
+
if (!_.includes(_.values(trades_status), false)) {
|
|
45
47
|
cb(exchange_pair_trades)
|
|
46
48
|
}
|
|
47
49
|
})
|
|
48
50
|
} else if (exchange.get_all_trades) {
|
|
49
51
|
exchange.get_all_trades(TRADES_TIMEFRAME, function (res) {
|
|
50
|
-
for (let pair of pair_list) {
|
|
51
|
-
_.set(status, [exchange + pair], true)
|
|
52
|
-
}
|
|
53
52
|
if (res.success) {
|
|
54
|
-
res.body(trade => {
|
|
53
|
+
res.body((trade) => {
|
|
55
54
|
let pair = trade.pair
|
|
56
55
|
if (!_.get(exchange_pair_trades, [exchange_id, pair])) {
|
|
57
56
|
_.set(exchange_pair_trades, [exchange_id, pair], [])
|
|
58
57
|
}
|
|
59
58
|
exchange_pair_trades[exchange][pair].push(trade)
|
|
60
|
-
})
|
|
59
|
+
})
|
|
61
60
|
} else {
|
|
62
61
|
if (exchange_pair_trades[exchange]) {
|
|
63
62
|
delete exchange_pair_trades[exchange][pair]
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
|
-
|
|
65
|
+
for (let pair of pair_list) {
|
|
66
|
+
_.set(trades_status, [exchange + pair], true)
|
|
67
|
+
}
|
|
68
|
+
if (!_.includes(_.values(trades_status), false)) {
|
|
67
69
|
cb(exchange_pair_trades)
|
|
68
|
-
}
|
|
70
|
+
}
|
|
69
71
|
})
|
|
70
72
|
} else if (exchange.get_trades_ws) {
|
|
71
|
-
if (exchange.
|
|
72
|
-
exchange.ws_account()
|
|
73
|
+
if (exchange.ws_trades_status().trading === 'n-opened') exchange.ws_account()
|
|
73
74
|
for (let pair of pair_list) {
|
|
74
75
|
exchange.get_trades_ws(pair, TRADES_TIMEFRAME, function (res) {
|
|
75
|
-
_.set(status, [exchange + pair], true)
|
|
76
76
|
if (res.success) {
|
|
77
77
|
_.set(exchange_pair_trades, [exchange_id, pair], res.body)
|
|
78
78
|
} else {
|
|
@@ -80,7 +80,8 @@ module.exports.get_exchanges_trades = function (Exchanges, exchange_pair_dict, c
|
|
|
80
80
|
delete exchange_pair_trades[exchange][pair]
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
_.set(trades_status, [exchange + pair], true)
|
|
84
|
+
if (!_.includes(_.values(trades_status), false)) {
|
|
84
85
|
cb(exchange_pair_trades)
|
|
85
86
|
}
|
|
86
87
|
})
|
|
@@ -88,7 +89,6 @@ module.exports.get_exchanges_trades = function (Exchanges, exchange_pair_dict, c
|
|
|
88
89
|
} else if (exchange.get_trades) {
|
|
89
90
|
for (let pair of pair_list) {
|
|
90
91
|
exchange.get_trades(pair, TRADES_TIMEFRAME, function (res) {
|
|
91
|
-
_.set(status, [exchange + pair], true)
|
|
92
92
|
if (res.success) {
|
|
93
93
|
_.set(exchange_pair_trades, [exchange_id, pair], res.body)
|
|
94
94
|
} else {
|
|
@@ -96,7 +96,8 @@ module.exports.get_exchanges_trades = function (Exchanges, exchange_pair_dict, c
|
|
|
96
96
|
delete exchange_pair_trades[exchange][pair]
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
_.set(trades_status, [exchange + pair], true)
|
|
100
|
+
if (!_.includes(_.values(trades_status), false)) {
|
|
100
101
|
cb(exchange_pair_trades)
|
|
101
102
|
}
|
|
102
103
|
})
|
|
@@ -104,4 +105,4 @@ module.exports.get_exchanges_trades = function (Exchanges, exchange_pair_dict, c
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
}
|
|
108
|
+
}
|
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.156",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
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.109",
|
|
21
21
|
"@icgio/icg-exchanges-data": "^1.6.57",
|
|
22
22
|
"@icgio/icg-utils": "^1.7.30",
|
|
23
23
|
"influx": "^5.7.0",
|