| | |
| | | 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"); |
| | | } |
| | | } |
| | | |
| | |
| | | map.put("low", low.setScale(decimal, RoundingMode.HALF_UP)); |
| | | map.put("volume", kline.getVolume()); |
| | | |
| | | //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) { |
| | | map.put("close", realtime.getClose().setScale(decimal, RoundingMode.HALF_UP)); |
| | | } |
| | | BeforeClose beforeClose = dataDBService.getBeforeClose(kline.getSymbol(), line, ts, realtime); |
| | | if (beforeClose != null) { |
| | | map.put("high", beforeClose.getMaxClose().setScale(decimal, RoundingMode.HALF_UP)); |
| | | map.put("low", beforeClose.getMinClose().setScale(decimal, RoundingMode.HALF_UP)); |
| | | } |
| | | 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; |