-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
38 lines (32 loc) · 887 Bytes
/
index.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
'use strict';
const SecondBoard = require('./lib/secondBoard.js');
const MainBoard = require('./lib/mainBoard.js');
const utils = require('./lib/utils.js');
module.exports = {
market: {
coins,
ticker,
},
board: {
SecondBoard,
MainBoard
}
}
async function coins() {
const secondBoardCoins = await getSecondBoardCoins();
return getMainBoardCoins().concat(secondBoardCoins);
}
async function ticker(symbol, suffix = 'cny') {
symbol = utils.removeSuffix(symbol, suffix);
if (getMainBoardCoins().includes(symbol)) {
return await MainBoard.getCurrentPrice(symbol, suffix);
} else {
return await SecondBoard.getCurrentPrice(symbol, suffix);
}
}
async function getSecondBoardCoins() {
return (await SecondBoard.currencys()).data || [];
}
function getMainBoardCoins() {
return ['btc', 'ltc'];
}