Administrator
2026-06-02 b78e68890f8277d3c3c322cd96f24c3194417667
refactor(okxNewPrice): 统一WebSocket登录逻辑并优化频道处理器配置

- 修改OkxGridWsClient中连接断开后的处理逻辑,移除公共/私有区分,统一调用wsLogin()
- 将条件单处理器从私有WebSocket迁移到业务WebSocket(/v5/business)
- 更新日志信息以反映新的WebSocket连接配置:业务端包含K线和条件单,私有端仅包含持仓
- 简化WebSocket客户端管理器中的注释描述,明确区分业务和私有通道功能
2 files modified
14 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxWebSocketClientManager.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
@@ -137,11 +137,7 @@
                    isConnecting.set(false);
                    if (sharedExecutor != null && !sharedExecutor.isShutdown()) {
                        resetHeartbeatTimer();
                        if (isPublic) {
                            subscribeAllHandlers();
                        } else {
                            wsLogin();
                        }
                        wsLogin();
                    }
                }
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxWebSocketClientManager.java
@@ -105,18 +105,18 @@
            gridTradeService.init();
            // 4. 创建 WS 客户端并注册频道处理器
            // 公共 WS:candle1m(K线数据)
            // 业务 WS(/v5/business):candle1m + orders-algo(K线 + 条件单)
            gridWsClientPublic = new OkxGridWsClient(primaryAccount, true);
            gridWsClientPublic.addChannelHandler(new OkxKlineChannelHandler(okxConfig.getInstId(), gridTradeService));
            gridWsClientPublic.addChannelHandler(new OkxAlgoOrdersChannelHandler(okxConfig.getInstId(), gridTradeService));
            gridWsClientPublic.init();
            // 私有 WS:positions + orders-algo(持仓 + 条件单)
            // 私有 WS(/v5/private):positions(持仓)
            gridWsClientPrivate = new OkxGridWsClient(primaryAccount, false);
            gridWsClientPrivate.addChannelHandler(new OkxPositionsChannelHandler(okxConfig.getInstId(), gridTradeService));
            gridWsClientPrivate.addChannelHandler(new OkxAlgoOrdersChannelHandler(okxConfig.getInstId(), gridTradeService));
            gridWsClientPrivate.init();
            log.info("[OKX-Manager] WS已连接, 公共: candle1m, 私有: positions/orders-algo");
            log.info("[OKX-Manager] WS已连接, business: candle1m/orders-algo, private: positions");
            // 5. 激活策略,等待首根 K 线触发基底双开
            gridTradeService.startGrid();