|
@@ -443,4 +443,81 @@ public class StockPoolServiceImpl implements IStockPoolService {
|
|
|
log.info("[补全历史数据] {}", message);
|
|
log.info("[补全历史数据] {}", message);
|
|
|
return message;
|
|
return message;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String updateStrongPoolTenDayGain(LocalDate importDate) {
|
|
|
|
|
+ log.info("[强势池10天涨幅] 开始更新,导入日期: {}", importDate);
|
|
|
|
|
+
|
|
|
|
|
+ // 查询10天内入池的强势池股票(poolType=2)
|
|
|
|
|
+ LocalDate tenDaysAgo = importDate.minusDays(10);
|
|
|
|
|
+ LambdaQueryWrapper<StockPool> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(StockPool::getPoolType, 2)
|
|
|
|
|
+ .ge(StockPool::getAddDate, tenDaysAgo)
|
|
|
|
|
+ .lt(StockPool::getAddDate, importDate)
|
|
|
|
|
+ .in(StockPool::getStatus, 1, 2);
|
|
|
|
|
+
|
|
|
|
|
+ List<StockPool> poolsToUpdate = baseMapper.selectList(lqw);
|
|
|
|
|
+
|
|
|
|
|
+ if (poolsToUpdate.isEmpty()) {
|
|
|
|
|
+ String message = "没有需要更新的强势池股票(10天内入池)";
|
|
|
|
|
+ log.info("[强势池10天涨幅] {}", message);
|
|
|
|
|
+ return message;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ log.info("[强势池10天涨幅] 找到 {} 只需要更新的股票", poolsToUpdate.size());
|
|
|
|
|
+
|
|
|
|
|
+ int updatedCount = 0;
|
|
|
|
|
+ int skippedCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (StockPool pool : poolsToUpdate) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String stockCode = pool.getStockCode();
|
|
|
|
|
+ LocalDate addDate = pool.getAddDate();
|
|
|
|
|
+ BigDecimal closePrice = pool.getClosePrice();
|
|
|
|
|
+
|
|
|
|
|
+ if (closePrice == null || closePrice.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
+ log.warn("[强势池10天涨幅] 股票 {} 收盘价为空或为0,跳过", stockCode);
|
|
|
|
|
+ skippedCount++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询从入池日到当前导入日的最高价
|
|
|
|
|
+ BigDecimal maxHighPrice = stockPoolHistoryMapper.selectMaxHighPriceInRange(
|
|
|
|
|
+ stockCode, addDate, importDate);
|
|
|
|
|
+
|
|
|
|
|
+ if (maxHighPrice == null) {
|
|
|
|
|
+ log.warn("[强势池10天涨幅] 股票 {} 在 [{}, {}] 范围内没有历史数据,跳过",
|
|
|
|
|
+ stockCode, addDate, importDate);
|
|
|
|
|
+ skippedCount++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 计算涨幅:(最高价 - 入池收盘价) / 入池收盘价 * 100
|
|
|
|
|
+ BigDecimal tenDayGain = maxHighPrice.subtract(closePrice)
|
|
|
|
|
+ .divide(closePrice, 4, RoundingMode.HALF_UP)
|
|
|
|
|
+ .multiply(new BigDecimal("100"))
|
|
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
+
|
|
|
|
|
+ pool.setNextDayGain(tenDayGain);
|
|
|
|
|
+ pool.setNextDayHigh(maxHighPrice);
|
|
|
|
|
+ pool.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
+ baseMapper.updateById(pool);
|
|
|
|
|
+
|
|
|
|
|
+ updatedCount++;
|
|
|
|
|
+
|
|
|
|
|
+ log.debug("[强势池10天涨幅] 股票 {} 更新成功,入池日: {}, 跟踪天数: {}, 最高价: {}, 涨幅: {}%",
|
|
|
|
|
+ stockCode, addDate, importDate.toEpochDay() - addDate.toEpochDay() + 1,
|
|
|
|
|
+ maxHighPrice, tenDayGain);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[强势池10天涨幅] 股票 {} 更新失败: {}",
|
|
|
|
|
+ pool.getStockCode(), e.getMessage(), e);
|
|
|
|
|
+ skippedCount++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String message = String.format("更新完成!成功 %d 条,跳过 %d 条", updatedCount, skippedCount);
|
|
|
|
|
+ log.info("[强势池10天涨幅] {}", message);
|
|
|
|
|
+ return message;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|