saveGridTrade = async (logger, rawData, order) => {
  const {
    symbol,
    featureToggle: { notifyDebug },
    symbolConfiguration: {
      buy: { gridTrade: buyGridTrade },
      sell: { gridTrade: sellGridTrade }
    }
  } = rawData;
  // Assumed grid trade in the symbol configuration is already up to date.
  const { side, type, currentGridTradeIndex } = order;

  const newGridTrade = {
    buy: buyGridTrade,
    sell: sellGridTrade
  };
  logger.info(
    { side, currentGridTradeIndex, newGridTrade },
    'Grid trade before updating'
  );

  const selectedSide = side.toLowerCase();

  const currentGridTrade = newGridTrade[selectedSide][currentGridTradeIndex];

  currentGridTrade.executed = true;
  currentGridTrade.executedOrder = order;

  newGridTrade[selectedSide][currentGridTradeIndex] = currentGridTrade;
  logger.info({ symbol, newGridTrade }, 'Grid Trade updated');

  if (notifyDebug) {
    slack.sendMessage(
      `*${symbol}* ${side.toUpperCase()} Grid Trade Updated: *${type}*\n` +
        `- Updated Gird Trade: \`\`\`${JSON.stringify(
          currentGridTrade,
          undefined,
          2
        )}\`\`\``,
      { symbol, apiLimit: getAPILimit(logger) }
    );
  }
  return saveSymbolGridTrade(logger, symbol, newGridTrade);
}
Save grid trade to database

@param {*} logger
@param {*} rawData
@param {*} order