KKSU
2024-09-30 36be00e0f3cbe0d559c646fd2977e6e3a74aa6f9
src/main/java/com/xcong/excoin/modules/exchange/service/impl/HandleKlineServiceImpl.java
@@ -49,7 +49,41 @@
                newPrice=exchangeTrade.getPrice();
            }
        }
        // 更新今日高地价
        BigDecimal min=BigDecimal.ZERO;
        BigDecimal max=BigDecimal.ZERO;
        BigDecimal vol = BigDecimal.ZERO;
        for (ExchangeTrade exchangeTrade : trades) {
            if(exchangeTrade==null){
                continue;
            }
            if(min.compareTo(BigDecimal.ZERO)==0){
                min = exchangeTrade.getPrice();
            }else{
                min=exchangeTrade.getPrice().min(min);
            }
            max=exchangeTrade.getPrice().max(max);
            vol=vol.add(exchangeTrade.getAmount());
        }
        Object o = redisUtils.get(symbolUsdt);
        if(o!=null){
            Candlestick today =   (Candlestick)o;
            today.setVolume(today.getVolume()==null?BigDecimal.ZERO:today.getVolume());
            today.setHigh(today.getHigh().max(max));
            today.setLow(today.getLow().min(min));
            today.setVolume(today.getVolume().add(vol));
            redisUtils.set(symbolUsdt,today);
        }else{
            Candlestick today =   new Candlestick();
            today.setClose(newPrice);
            today.setLow(newPrice);
            today.setHigh(newPrice);
            today.setVolume(BigDecimal.ZERO);
            today.setHigh(today.getHigh().max(max));
            today.setLow(today.getLow().min(min));
            today.setVolume(vol);
            redisUtils.set(symbolUsdt,today);
        }
        // 存入redis,websocket去取
        String key = "NEW_KINE_{}";
        key = StrUtil.format(key, symbolUsdt);
@@ -60,4 +94,5 @@
        }
    }
}