| | |
| | | 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"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | //if (line.equalsIgnoreCase(Kline.PERIOD_15MIN) || line.equalsIgnoreCase(Kline.PERIOD_30MIN) || line.equalsIgnoreCase(Kline.PERIOD_60MIN)) { |
| | | if (i == data.size() - 1) { |
| | | //获取当前价格 |
| | | Realtime realtime = DataCache.getLatestRealTime(symbol); |
| | | if (realtime != null) { |
| | | if (realtime != null && realtime.getClose() != null && realtime.getClose().compareTo(BigDecimal.ZERO) > 0) { |
| | | map.put("close", realtime.getClose().setScale(decimal, RoundingMode.HALF_UP)); |
| | | } |
| | | BeforeClose beforeClose = dataDBService.getBeforeClose(kline.getSymbol(), line, ts, realtime); |
| | |
| | | map.put("high", beforeClose.getMaxClose().setScale(decimal, RoundingMode.HALF_UP)); |
| | | map.put("low", beforeClose.getMinClose().setScale(decimal, RoundingMode.HALF_UP)); |
| | | } |
| | | BigDecimal openVal = (BigDecimal) map.get("open"); |
| | | BigDecimal closeVal = (BigDecimal) map.get("close"); |
| | | BigDecimal highVal = (BigDecimal) map.get("high"); |
| | | BigDecimal lowVal = (BigDecimal) map.get("low"); |
| | | if (openVal != null && closeVal != null) { |
| | | map.put("high", highVal.max(openVal).max(closeVal)); |
| | | map.put("low", lowVal.min(openVal).min(closeVal)); |
| | | } |
| | | } |
| | | //} |
| | | list.add(map); |