forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.fetchTickers.js
49 lines (32 loc) · 1.27 KB
/
test.fetchTickers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict'
// ----------------------------------------------------------------------------
const testTicker = require ('./test.ticker.js')
// ----------------------------------------------------------------------------
module.exports = async (exchange, symbol) => {
const method = 'fetchTickers'
const skippedExchanges = [
'binance',
'digifinex',
'currencycom',
]
if (skippedExchanges.includes (exchange.id)) {
console.log (exchange.id, 'found in ignored exchanges, skipping ' + method + '...')
return
}
if (exchange.has[method]) {
// log ('fetching all tickers at once...')
let tickers = undefined
try {
tickers = await exchange[method] ()
console.log ('fetched all', Object.keys (tickers).length, 'tickers')
} catch (e) {
console.log ('failed to fetch all tickers, fetching multiple tickers at once...')
tickers = await exchange[method] ([ symbol ])
console.log ('fetched', Object.keys (tickers).length, 'tickers')
}
Object.values (tickers).forEach ((ticker) => testTicker (exchange, ticker, undefined, symbol))
return tickers
} else {
console.log (method + '() is not supported')
}
}