Administrator
2025-12-10 6933ef2edc3911311976cfc0f077c395be510f34
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
@@ -268,41 +268,8 @@
            AccountWs.handleEvent(response, redisUtils);
        } else if (PositionsWs.POSITIONSWS_CHANNEL.equals(channel)) {
            PositionsWs.handleEvent(response, redisUtils);
            String posKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":pos";
            String pos = (String) redisUtils.get(posKey);
            if (StrUtil.isBlank(pos)) {
                log.error("未获取到持仓数量");
                TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.INIT.getValue());
                return;
            }
            String state = (String) redisUtils.get(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state");
            if (OrderParamEnums.STATE_3.getValue().equals(state)){
                log.error("持仓盈亏超过下单总保证金,止损冷静一天......");
                TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.OUT.getValue());
                return;
            }
            String uplKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":upl";
            String upl = (String) redisUtils.get(uplKey);
            if (StrUtil.isBlank(upl)){
                upl = "0";
            }
            String totalOrderUsdtKey = AccountWs.ACCOUNTWS_CHANNEL + ":" + CoinEnums.USDT.getCode() + ":totalOrderUsdt";
            String totalOrderUsdt = (String) redisUtils.get(totalOrderUsdtKey);
            BigDecimal multiply = new BigDecimal(upl).multiply(new BigDecimal("-1"));
            if (new BigDecimal(totalOrderUsdt).compareTo(multiply) < 0) {
                log.error("持仓盈亏超过下单总保证金,止损冷静一天......");
                TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.OUT.getValue());
                return;
            }
            String side = caoZuoService.caoZuo();
            if (StrUtil.isNotBlank(pos)) {
                TradeOrderWs.orderEvent(webSocketClient, redisUtils, side);
            }
        } else if (BalanceAndPositionWs.CHANNEL_NAME.equals(channel)) {
            BalanceAndPositionWs.handleEvent(response);
        }