| | |
| | | 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)); |
| | | //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 && 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); |
| | | if (beforeClose != null) { |
| | | 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)); |
| | | } |
| | | } |
| | | 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; |