-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
29 lines (23 loc) · 814 Bytes
/
api.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
const axios = require('axios');
async function exchangeInfo() {
const response = await axios.get("https://api.binance.com/api/v3/exchangeInfo");
const symbols = response.data.symbols.filter(s => s.status === 'TRADING');
const result = symbols.map(s => {
const minQtyFilter = s.filters.find(f => f.filterType === 'LOT_SIZE');
const minQty = parseFloat(minQtyFilter.minQty);
if (Math.floor(minQty) === minQty) {
decimals = 0;
}else{
decimals = minQty.toString().split(".")[1].length || 0;
}
return {
symbol: s.symbol,
base: s.baseAsset,
quote: s.quoteAsset,
minQty: minQty,
decimals: decimals
};
});
return result;
}
module.exports = { exchangeInfo }