新版仿ok交易所-后端
1
zyy
2025-10-15 172e68549495c33f156ced3a83d151d422941ca8
trading-order-admin/src/main/java/com/yami/trading/admin/task/RealtimeWebsocketServer.java
@@ -4,6 +4,7 @@
import com.yami.trading.bean.data.domain.Realtime;
import com.yami.trading.bean.data.domain.Trade;
import com.yami.trading.bean.item.domain.Item;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.Arith;
import com.yami.trading.huobi.data.AdjustmentValueCache;
import com.yami.trading.huobi.data.DataCache;
@@ -29,7 +30,7 @@
import java.util.stream.Collectors;
/**
 *
 *
 * 深度、近期交易记录 websocket启动服务
 */
@Component
@@ -91,6 +92,10 @@
         Item item = itemService.findBySymbol(symbol);
         symbol = item.getSymbol();
         item = this.itemService.findBySymbol(symbol);
         //停牌时不更新
         if (itemService.isSuspended(symbol)) {
            return;
         }
         Double currentValue = AdjustmentValueCache.getCurrentValue().get(symbol).doubleValue();
         double close = event.getTicker().getClose().doubleValue();
         double vol = event.getTicker().getVol().doubleValue();
@@ -108,8 +113,10 @@
         if (currentValue != null && currentValue != 0) {
            realtime.setClose(new BigDecimal(Arith.add(close, currentValue.doubleValue())));
            realtime.setVolume(new BigDecimal(Arith.add(vol, Arith.mul(Arith.div(currentValue, close), vol))));
            realtime.setAmount(new BigDecimal(Arith.add(amount, Arith.mul(Arith.div(currentValue, close), amount))));
            //realtime.setVolume(new BigDecimal(Arith.add(vol, Arith.mul(Arith.div(currentValue, close), vol))));
            //realtime.setAmount(new BigDecimal(Arith.add(amount, Arith.mul(Arith.div(currentValue, close), amount))));
            realtime.setHigh(realtime.getHigh().add(BigDecimal.valueOf(currentValue)));
            realtime.setLow(realtime.getLow().add(BigDecimal.valueOf(currentValue)));
         }
         Double high = DataCache.getRealtimeHigh().get(symbol);
@@ -130,19 +137,22 @@
               realtime.setAmount(realtime.getAmount().multiply(item.getMultiple()));
            }
            if (high != null && high >= realtime.getClose().doubleValue()) {
            /*if (high != null && high >= realtime.getClose().doubleValue()) {
               realtime.setHigh(new BigDecimal(high));
            }
            if (low != null && low <= realtime.getClose().doubleValue()) {
               realtime.setLow(new BigDecimal(low));
            }
            }*/
            Double h24Before = DataCache.getRealtime24HBeforeOpen().get(symbol);
            /*ouble h24Before = DataCache.getRealtime24HBeforeOpen().get(symbol);
            if (h24Before != null) {
               realtime.setOpen(new BigDecimal(h24Before));
            }
            }*/
            /*if (realtime.getSymbol().equals("axsusdt")) {
               System.out.println("axsusdt2" + realtime);
            }*/
            DataCache.putRealtime(symbol, realtime);
            // System.out.println(JSONObject.toJSONString(realtime));
         }