I am running a cryptocurrency bot that needs 2 things:

  1. Get a list of all the coins every 10 minutes or a similar frequency
  2. Get a list of all the prices for each coin

The problem lies in 2 where I cannot query all 1500+ coins at one go. I am chunking them into 50 coins per chunk and querying the prices of 50 coins and then moving to the next chunk.

Another aspect to consider is the rank of the coin, I don't want all the coin prices, just looking at the top 500 and refreshing their prices every minute or so works.

Given the complex circumstances, I wrote 2 functions that handle everything. These functions are part of a class and a single variable called coins should be able to maintain the updated list of coins at any time.

Is there a better way to achieve this task?

    let self = this
    async.eachSeries(self.coins, async(item, callback)=>{
            self.onRefresh(await self.priceMulti(item, "EUR,USD,BTC"))
        await self.delay(self.priceRefreshFrequency)
    async (error) => { 
        self.coins = self.parseCoins(await self.coinsList())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.