@icgio/icg-exchanges-wrapper 1.9.150 → 1.9.151
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.
|
@@ -2,8 +2,11 @@ const _ = require('lodash')
|
|
|
2
2
|
|
|
3
3
|
const DEFAULT_ORDERBOOK_LEVEL = 50
|
|
4
4
|
|
|
5
|
-
let first_time = {},
|
|
6
|
-
|
|
5
|
+
let first_time = {},
|
|
6
|
+
checked_rates = {},
|
|
7
|
+
exchange_pair_rates = {},
|
|
8
|
+
pair_exchange_rates = {}
|
|
9
|
+
module.exports.get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enabled = true) {
|
|
7
10
|
checked_rates = {}
|
|
8
11
|
if (!Array.isArray(Exchanges)) {
|
|
9
12
|
console.error('Exchanges should be an array')
|
|
@@ -11,10 +14,13 @@ module.exports.get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb
|
|
|
11
14
|
} else {
|
|
12
15
|
for (let Exchange of Exchanges) {
|
|
13
16
|
let Exchange_name = _.upperFirst(Exchange.name)
|
|
14
|
-
if (checked_rates[Exchange_name])
|
|
17
|
+
if (checked_rates[Exchange_name]) {
|
|
15
18
|
continue
|
|
19
|
+
}
|
|
16
20
|
checked_rates[Exchange_name] = true
|
|
17
|
-
if (!exchange_pair_dict[Exchange_name])
|
|
21
|
+
if (!exchange_pair_dict[Exchange_name]) {
|
|
22
|
+
continue
|
|
23
|
+
}
|
|
18
24
|
if (Exchange.ws_market && ws_enabled) {
|
|
19
25
|
if (!first_time[Exchange_name]) {
|
|
20
26
|
Exchange.ws_market(exchange_pair_dict[Exchange_name])
|
|
@@ -58,8 +64,10 @@ module.exports.get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb
|
|
|
58
64
|
cb({ exchange_pair_rates, pair_exchange_rates })
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
let checked_market_history = {},
|
|
62
|
-
|
|
67
|
+
let checked_market_history = {},
|
|
68
|
+
exchange_pair_market_history = {},
|
|
69
|
+
pair_exchange_market_history = {}
|
|
70
|
+
module.exports.get_exchanges_market_history = function (Exchanges, exchange_pair_dict, timeframe_in_ms, cb, ws_enabled = true) {
|
|
63
71
|
checked_market_history = {}
|
|
64
72
|
if (!Array.isArray(Exchanges)) {
|
|
65
73
|
console.error('Exchanges should be an array')
|
|
@@ -67,10 +75,13 @@ module.exports.get_exchanges_market_history = function (Exchanges, exchange_pair
|
|
|
67
75
|
} else {
|
|
68
76
|
for (let Exchange of Exchanges) {
|
|
69
77
|
let Exchange_name = _.upperFirst(Exchange.name)
|
|
70
|
-
if (checked_market_history[Exchange_name])
|
|
78
|
+
if (checked_market_history[Exchange_name]) {
|
|
71
79
|
continue
|
|
80
|
+
}
|
|
72
81
|
checked_market_history[Exchange_name] = true
|
|
73
|
-
if (!exchange_pair_dict[Exchange_name])
|
|
82
|
+
if (!exchange_pair_dict[Exchange_name]) {
|
|
83
|
+
continue
|
|
84
|
+
}
|
|
74
85
|
if (Exchange.ws_market && ws_enabled) {
|
|
75
86
|
if (!first_time[Exchange_name]) {
|
|
76
87
|
Exchange.ws_market(exchange_pair_dict[Exchange_name])
|
|
@@ -113,3 +124,43 @@ module.exports.get_exchanges_market_history = function (Exchanges, exchange_pair
|
|
|
113
124
|
}
|
|
114
125
|
cb({ exchange_pair_market_history, pair_exchange_market_history })
|
|
115
126
|
}
|
|
127
|
+
|
|
128
|
+
let checked_ohlcv = {},
|
|
129
|
+
exchange_pair_ohlcv = {},
|
|
130
|
+
pair_exchange_ohlcv = {}
|
|
131
|
+
module.exports.get_exchanges_ohlcv = function (Exchanges, exchange_pair_dict, from_in_ms, to_in_ms, cb) {
|
|
132
|
+
checked_ohlcv = {}
|
|
133
|
+
if (!Array.isArray(Exchanges)) {
|
|
134
|
+
console.error('Exchanges should be an array')
|
|
135
|
+
return
|
|
136
|
+
} else {
|
|
137
|
+
for (let Exchange of Exchanges) {
|
|
138
|
+
let Exchange_name = _.upperFirst(Exchange.name)
|
|
139
|
+
if (checked_ohlcv[Exchange_name]) {
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
checked_ohlcv[Exchange_name] = true
|
|
143
|
+
if (!exchange_pair_dict[Exchange_name]) {
|
|
144
|
+
continue
|
|
145
|
+
}
|
|
146
|
+
if (Exchange.ohlcv) {
|
|
147
|
+
for (let pair of exchange_pair_dict[Exchange_name]) {
|
|
148
|
+
Exchange.ohlcv(pair, from_in_ms, to_in_ms, function (res) {
|
|
149
|
+
if (res.success) {
|
|
150
|
+
_.set(exchange_pair_ohlcv, [Exchange_name, pair], res.body)
|
|
151
|
+
_.set(pair_exchange_ohlcv, [pair, Exchange_name], res.body)
|
|
152
|
+
} else {
|
|
153
|
+
if (exchange_pair_ohlcv[Exchange_name]) {
|
|
154
|
+
delete exchange_pair_ohlcv[Exchange_name][pair]
|
|
155
|
+
}
|
|
156
|
+
if (pair_exchange_ohlcv[pair]) {
|
|
157
|
+
delete pair_exchange_ohlcv[pair][Exchange_name]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
cb({ exchange_pair_ohlcv, pair_exchange_ohlcv })
|
|
166
|
+
}
|
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.151",
|
|
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.107",
|
|
21
21
|
"@icgio/icg-exchanges-data": "^1.6.56",
|
|
22
22
|
"@icgio/icg-utils": "^1.7.30",
|
|
23
23
|
"influx": "^5.7.0",
|