private void calTrendMaMonitor(
     TrendMaMonitor trendMaMonitor, Date date, BigDecimal prodPrice, BigDecimal maPrice) {
   if (trendMaMonitor.getCalDate() == null) {
     trendMaMonitor.setCalDate(date);
     trendMaMonitor.setProdPrice(prodPrice);
     trendMaMonitor.setMaPrice(maPrice);
     trendMaMonitor.setDiff(maPrice.subtract(prodPrice).divide(prodPrice, 4, RoundingMode.FLOOR));
     trendMaMonitor.setTrendDays(1);
   } else if (trendMaMonitor.getCalDate().before(date)) {
     BigDecimal lastDiff = trendMaMonitor.getDiff();
     BigDecimal diff = maPrice.subtract(prodPrice).divide(prodPrice, 4, RoundingMode.FLOOR);
     trendMaMonitor.setCalDate(date);
     trendMaMonitor.setProdPrice(prodPrice);
     trendMaMonitor.setMaPrice(maPrice);
     trendMaMonitor.setDiff(diff);
     if (diff.compareTo(BigDecimal.ZERO) == 0) {
       trendMaMonitor.setTrendDays(trendMaMonitor.getTrendDays() + 1);
       trendMaMonitor.setReturnDays(0);
     } else if (lastDiff.compareTo(BigDecimal.ZERO) == 0) {
       trendMaMonitor.setTrendDays(trendMaMonitor.getTrendDays() + 1);
       trendMaMonitor.setReturnDays(null);
     } else if (diff.compareTo(BigDecimal.ZERO) * lastDiff.compareTo(BigDecimal.ZERO) > 0) {
       trendMaMonitor.setTrendDays(trendMaMonitor.getTrendDays() + 1);
       BigDecimal absDiff = diff.abs();
       BigDecimal absLastDiff = lastDiff.abs();
       if (absLastDiff.compareTo(absDiff) > 0) {
         int returnDays =
             absDiff.divide(absLastDiff.subtract(absDiff), 0, RoundingMode.UP).intValue();
         trendMaMonitor.setReturnDays(returnDays);
       } else {
         trendMaMonitor.setReturnDays(null);
       }
     } else if (diff.compareTo(BigDecimal.ZERO) * lastDiff.compareTo(BigDecimal.ZERO) < 0) {
       trendMaMonitor.setTrendDays(1);
       trendMaMonitor.setReturnDays(0);
     }
   }
 }