postProcessConfiguration = async (
  logger,
  configuration,
  { symbolGridTrade, symbol }
) => {
  const newConfiguration = configuration;

  const lastBuyPriceDoc = await getLastBuyPrice(logger, symbol);
  const lastBuyPrice = _.get(lastBuyPriceDoc, 'lastBuyPrice', null);

  // Retrieve grid trade and determine current grid trade
  ['buy', 'sell'].forEach(side => {
    let currentGridTradeIndex = -1;
    let currentGridTrade = null;
    let overridenGridTrade = configuration[side].gridTrade;

    // If symbol grid trade is stored and has executed value at least one time
    if (
      symbolGridTrade[side] &&
      symbolGridTrade[side].some(g => g?.executed === true)
    ) {
      // Find executed grid trade
      symbolGridTrade[side].forEach((gridTrade, index) => {
        // If grid trade is executed, then override grid trade
        if (gridTrade?.executed) {
          overridenGridTrade[index] = gridTrade;
        }
      });

      // Calculate current grid trade
      overridenGridTrade.forEach((gridTrade, index) => {
        // If current grid trade is executed,
        if (gridTrade?.executed) {
          // If next gird trade exists, then get next grid trade as current buy grid trade
          if (overridenGridTrade[index + 1]) {
            currentGridTradeIndex = index + 1;
            currentGridTrade = overridenGridTrade[index + 1];
          } else {
            // If next gird trade does not exist, then do not set current grid trade
            currentGridTradeIndex = -1;
            currentGridTrade = null;
          }
        }
      });
    } else if (
      side === 'buy' &&
      lastBuyPrice > 0 &&
      overridenGridTrade[1] !== undefined
    ) {
      // If none of grid trade is executed, side is buy, last buy is recorded, 2nd grid trade is defined

      currentGridTradeIndex = 1;
      [, currentGridTrade] = overridenGridTrade;
    } else if (
      side === 'buy' &&
      lastBuyPrice > 0 &&
      overridenGridTrade[1] === undefined
    ) {
      // If none of grid trade is executed, side is buy, last buy is recorded, 2nd grid trade is not defined

      currentGridTradeIndex = -1;
      currentGridTrade = null;
    } else {
      // Otherwise, get first grid trade as current grid trade

      currentGridTradeIndex = 0;
      [currentGridTrade] = overridenGridTrade;
    }

    // Set extra parameters for grid trade if not defined
    overridenGridTrade = overridenGridTrade.map(orgGridTrade => {
      const gridTrade = orgGridTrade;
      if (gridTrade.executed === undefined) {
        gridTrade.executed = false;
        gridTrade.executedOrder = null;
      }

      return gridTrade;
    });

    // If current grid trade index is -1, then it means grid is all executed.
    newConfiguration[side].currentGridTradeIndex = currentGridTradeIndex;
    newConfiguration[side].currentGridTrade = currentGridTrade;
    newConfiguration[side].gridTrade = overridenGridTrade;
  });

  return newConfiguration;
}
Post process configuration
- Retrieve grid trade and determine current grid trade
- If symbol grid trade is stored and has executed value, then use stored grid trade.

@param {*} logger
@param {*} configuration
@param {*} extraParams
@returns