Last active
November 6, 2018 18:52
-
-
Save Musinux/6f61fadd26091426efa7f5e738391b56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let removeDuplicate = (v, i, a) => a.indexOf(v) === i | |
async function getSymbolsNames (quoteAsset = 'BTC') { | |
// exchangeInfo : timezone , serverTime , rateLimits , exchangeFilters , symbols | |
// symbolsInfo : symbol, baseAsset, quoteAsset, status, icebergAllowed, orderTypes, filters | |
// orderTypes : [ 'LIMIT', 'LIMIT_MAKER', 'MARKET', 'STOP_LOSS_LIMIT', 'TAKE_PROFIT_LIMIT' ] | |
let exchangeInfo = await client.exchangeInfo() | |
let symbolsInfo = exchangeInfo.symbols | |
symbolsInfo = symbolsInfo.filter(elem => elem.status === 'TRADING') | |
symbolsInfo = symbolsInfo.filter(elem => elem.quoteAsset === quoteAsset) | |
let symbols = symbolsInfo.map(elem => elem.symbol) | |
let baseAssets = symbolsInfo.map(elem => elem.baseAsset).filter(removeDuplicate) | |
let quoteAssets = symbolsInfo.map(elem => elem.quoteAsset).filter(removeDuplicate) | |
// TODO understand filters | |
// const filters = symbolsInfo.map(elem => elem.filters) | |
return new Promise((resolve, reject) => resolve({ | |
symbols: symbols, | |
baseAssets: baseAssets, | |
quoteAssets: quoteAssets | |
})) | |
} | |
async function getSymbolsNames (quoteAsset = 'BTC') { | |
const exchangeInfo = await client.exchangeInfo() | |
let symbolsInfo = exchangeInfo.symbols | |
const symbols = [] | |
const baseAssets = [] | |
const quoteAssets = [] | |
// symbolsInfo = symbolsInfo.filter(elem => elem.status === 'TRADING' && elem.quoteAsset === quoteAsset) | |
symbolsInfo.forEach((elem, i) => { | |
if (elem.status !== 'TRADING' || elem.quoteAsset !== quoteAsset) { | |
return | |
} | |
symbols.push(elem) | |
if (removeDuplicate(elem, i)) { | |
baseAssets.push(elem.baseAsset) | |
quoteAssets.push(elem.quoteAsset) | |
} | |
}) | |
// TODO understand filters | |
// const filters = symbolsInfo.map(elem => elem.filters) | |
return { | |
symbols, | |
baseAssets, | |
quoteAssets | |
} | |
} | |
UserSchema.statics.findByEmail = async function findByEmail (email) { | |
// do stuff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment