From 8925858fb424100acd761178bfbe30c3cbb21c2b Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 10 Dec 2025 15:04:25 +0800
Subject: [PATCH] feat(okx): 添加OKX WebSocket认证和签名工具

---
 src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java |   32 +++-----------------------------
 1 files changed, 3 insertions(+), 29 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
index 28586c3..e79cd49 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
@@ -7,6 +7,7 @@
 import com.xcong.excoin.modules.okxNewPrice.celue.CaoZuoService;
 import com.xcong.excoin.modules.okxNewPrice.okxWs.*;
 import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.CoinEnums;
+import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.ExchangeInfoEnum;
 import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.OrderParamEnums;
 import com.xcong.excoin.modules.okxNewPrice.utils.SSLConfig;
 import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeService;
@@ -50,7 +51,6 @@
 
     private static final String WS_URL_MONIPAN = "wss://wspap.okx.com:8443/ws/v5/private";
     private static final String WS_URL_SHIPAN = "wss://ws.okx.com:8443/ws/v5/private";
-    private static final boolean INTERNET = false;
 
     /**
      * 订阅频道指令
@@ -123,7 +123,7 @@
             SSLConfig.configureSSL();
             System.setProperty("https.protocols", "TLSv1.2,TLSv1.3");
             String WS_URL = WS_URL_MONIPAN;
-            if (INTERNET){
+            if (ExchangeInfoEnum.OKX_UAT.isAccountType()){
                 WS_URL = WS_URL_SHIPAN;
             }
             URI uri = new URI(WS_URL);
@@ -268,34 +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");
-            String uplKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":upl";
-            String totalOrderUsdtKey = AccountWs.ACCOUNTWS_CHANNEL + ":" + CoinEnums.USDT.getCode() + ":totalOrderUsdt";
-
-            String upl =  ObjectUtil.isEmpty(redisUtils.get(uplKey)) ? "0" : (String)redisUtils.get(uplKey);
-
-            String totalOrderUsdt = (String) redisUtils.get(totalOrderUsdtKey);
-            BigDecimal multiply = new BigDecimal(upl).multiply(new BigDecimal("-1"));
-
-            if (new BigDecimal(totalOrderUsdt).compareTo(multiply) < 0 || OrderParamEnums.STATE_3.getValue().equals(state)) {
-                log.error("持仓盈亏超过下单总保证金,止损冷静一天......");
-                TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.OUT.getValue());
-                return;
-            }
-
             String side = caoZuoService.caoZuo();
-            if (StrUtil.isNotBlank(pos)) {
-                TradeOrderWs.orderEvent(webSocketClient, redisUtils, side);
-            }
+            TradeOrderWs.orderEvent(webSocketClient, redisUtils, side);
         } else if (BalanceAndPositionWs.CHANNEL_NAME.equals(channel)) {
             BalanceAndPositionWs.handleEvent(response);
         }

--
Gitblit v1.9.1