From 030e1d50c1f643137220f1ecf1d90ce39174204a Mon Sep 17 00:00:00 2001
From: dd <gitluke@outlook.com>
Date: Sat, 30 May 2026 01:58:54 +0800
Subject: [PATCH] 1
---
trading-order-admin/src/main/java/com/yami/trading/api/controller/KlineController.java | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/trading-order-admin/src/main/java/com/yami/trading/api/controller/KlineController.java b/trading-order-admin/src/main/java/com/yami/trading/api/controller/KlineController.java
index ef57068..61df12d 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/api/controller/KlineController.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/api/controller/KlineController.java
@@ -2,12 +2,17 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yami.trading.bean.data.domain.Kline;
+import com.yami.trading.bean.data.domain.Realtime;
+import com.yami.trading.bean.data.dto.BeforeClose;
import com.yami.trading.bean.ico.domain.Ico;
import com.yami.trading.bean.item.domain.Item;
import com.yami.trading.common.domain.Result;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.DateUtils;
import com.yami.trading.common.web.ResultObject;
+import com.yami.trading.huobi.data.AdjustmentValueCache;
+import com.yami.trading.huobi.data.DataCache;
+import com.yami.trading.huobi.data.internal.DataDBService;
import com.yami.trading.huobi.data.internal.KlineService;
import com.yami.trading.service.data.DataService;
import com.yami.trading.service.etf.MarketService;
@@ -46,6 +51,9 @@
private DataService dataService;
@Autowired
private IcoService icoService;
+
+ @Autowired
+ private DataDBService dataDBService;
@ApiOperation(value = "行情")
@GetMapping(HOBI + "getKline.action")
@@ -95,10 +103,27 @@
DateUtils.timeStamp2Date(String.valueOf(datum.getTs()), "MM-dd HH:mm"));
}
}
+
+ /*BigDecimal currentValue = AdjustmentValueCache.getCurrentValue().get(symbol);
+ if (currentValue != null) {
+ data.forEach(kline -> {
+ *//*logger.info("==currentValue==close:{}, low:{}, high:{}, open:{}, currentValue:{}",
+ kline.getClose(), kline.getLow(), kline.getHigh(), kline.getOpen(), currentValue);*//*
+ if (!kline.isAdjusted()){
+ if (kline.getClose().compareTo(kline.getLow()) >= 0 && kline.getClose().compareTo(kline.getHigh()) <= 0) {
+ kline.setClose(kline.getClose().add(currentValue));
+ }
+ kline.setOpen(kline.getOpen().add(currentValue));
+ kline.setLow(kline.getLow().add(currentValue));
+ kline.setHigh(kline.getHigh().add(currentValue));
+ kline.setAdjusted(true);
+ }
+ });
+ }*/
return Result.succeed(this.build(data, line, symbol));
} catch (Exception e) {
logger.error("getKline error", e);
- throw new YamiShopBindException("k线图获取失败");
+ throw new YamiShopBindException("Failed to obtain the K-line chart");
}
}
@@ -155,6 +180,31 @@
map.put("high", high.setScale(decimal, RoundingMode.HALF_UP));
map.put("low", low.setScale(decimal, RoundingMode.HALF_UP));
map.put("volume", kline.getVolume());
+
+ if (i == data.size() - 1) {
+ BigDecimal periodHigh = high;
+ BigDecimal periodLow = low;
+ BigDecimal closePrice = close;
+ Realtime realtime = DataCache.getLatestRealTime(symbol);
+ if (realtime != null && realtime.getClose() != null
+ && realtime.getClose().compareTo(BigDecimal.ZERO) > 0) {
+ closePrice = realtime.getClose();
+ map.put("close", closePrice.setScale(decimal, RoundingMode.HALF_UP));
+ }
+ BeforeClose beforeClose = dataDBService.getBeforeClose(kline.getSymbol(), line, ts, realtime);
+ if (beforeClose != null
+ && beforeClose.getMaxClose() != null && beforeClose.getMaxClose().compareTo(BigDecimal.ZERO) > 0
+ && beforeClose.getMinClose() != null && beforeClose.getMinClose().compareTo(BigDecimal.ZERO) > 0) {
+ periodHigh = periodHigh.max(beforeClose.getMaxClose());
+ periodLow = periodLow.min(beforeClose.getMinClose());
+ }
+ if (closePrice != null && closePrice.compareTo(BigDecimal.ZERO) > 0) {
+ periodHigh = periodHigh.max(closePrice);
+ periodLow = periodLow.min(closePrice);
+ }
+ map.put("high", periodHigh.setScale(decimal, RoundingMode.HALF_UP));
+ map.put("low", periodLow.setScale(decimal, RoundingMode.HALF_UP));
+ }
list.add(map);
}
return list;
--
Gitblit v1.9.3