I'm building a trading bot that needs to get stock names from separate files. But even I have used async function and await in my code, that doesn't work.
My index file init method.
const init = async () => {
    const symbols = await getDownTrendingStock();
    console.log("All stocks that are down: " + symbols);
    const doOrder = async () => {
        //do stuff
    }
    doOrder();
}
my getDownTrendeingStock file
const downStocks = []
function getDownTrendingStock () {
        for(i = 0; i < data.USDTPairs.length; i++){
      
            const USDTPair = data.USDTPairs[i] + "USDT";
      
            binance.prevDay(USDTPair, (error, prevDay, symbol) => {
                  if(prevDay.priceChangePercent < -2){
                      downStocks.push(symbol)
                  }
                 });
          }
          return downStocks;
}
I have tried to also use async in for loop because the getDownTrendinStock function returns an empty array before for loop is finished. I didn't find the right way to do that because I was confused with all async, promise and callback stuff. What is the right statement to use in this situation?
Output:
All stocks that are down: 
Wanted output:
All stocks that are down: [BTCUSDT, TRXUSDT, ATOMUSDT...]
 
     
     
    