demo
List<StockDayK> dayKLineList = getIndexDayKList(code, endDate, (count) * 5 + 1);
Map<LocalDate, List<StockDayK>> weekMap = dayKLineList.parallelStream()
.collect(Collectors.groupingBy(
((Function<StockDayK, LocalDate>) StockDayK::getDate)
.andThen(dates -> dates
.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)))
));
Map<LocalDate, List<StockDayK>> monthMap = dayKLineList.parallelStream()
.collect(Collectors.groupingBy(
((Function<StockDayK, LocalDate>) StockDayK::getDate)
.andThen(s -> LocalDate.of(s.getYear(), s.getMonthValue(), 1))
));
List<WeekEntity> klist = collect2.get(Signal.K).stream()
.collect(Collectors.toMap(WeekEntity::getCode, Function.identity(), (a, b) -> a.getChange() < b.getChange() ? a : b, HashMap::new))
.values()
.stream()
.sorted(Comparator.comparing(WeekEntity::getChange))
.limit(limit)
.collect(Collectors.toList());
Map<String, Map<IndexType, List<StockOptimizedIndex>>> collect = preDayList.stream()
.collect(Collectors.groupingBy(StockOptimizedIndex::getCode,
Collectors.groupingBy(StockOptimizedIndex::getType,
Collectors.collectingAndThen(Collectors.toList(), lists ->
lists.stream().sorted(Comparator.comparing(StockOptimizedIndex::getDate).reversed()).limit(2)
.collect(Collectors.toList())))));