| | |
| | | |
| | | 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.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; |
| | |
| | | private DataService dataService; |
| | | @Autowired |
| | | private IcoService icoService; |
| | | |
| | | @Autowired |
| | | private DataDBService dataDBService; |
| | | |
| | | @ApiOperation(value = "行情") |
| | | @GetMapping(HOBI + "getKline.action") |
| | |
| | | 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("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; |