fix: build markets requests and caching
This commit is contained in:
parent
0e7ca4e563
commit
21925ae145
4 changed files with 33 additions and 16 deletions
|
|
@ -56,6 +56,8 @@ function calculatePrice (side, amount, orderBook) {
|
|||
}
|
||||
|
||||
function _getMarkets (exchangeName, availableCryptos) {
|
||||
const prunedCryptos = _.compose(_.uniq, _.map(coinUtils.getEquivalentCode))(availableCryptos)
|
||||
|
||||
try {
|
||||
const exchange = new ccxt[exchangeName]()
|
||||
const cryptosToQuoteAgainst = ['USDT']
|
||||
|
|
@ -65,13 +67,13 @@ function _getMarkets (exchangeName, availableCryptos) {
|
|||
.then(_.filter(it => (it.type === 'spot' || it.spot)))
|
||||
.then(res =>
|
||||
_.reduce((acc, value) => {
|
||||
if (_.includes(value.base, availableCryptos) && _.includes(value.quote, currencyCodes)) {
|
||||
if (_.includes(value.base, prunedCryptos) && _.includes(value.quote, currencyCodes)) {
|
||||
if (value.quote === value.base) return acc
|
||||
|
||||
if (_.isNil(acc[value.quote])) {
|
||||
return { ...acc, [value.quote]: [value.base] }
|
||||
}
|
||||
|
||||
|
||||
acc[value.quote].push(value.base)
|
||||
}
|
||||
return acc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue