| | |
| | | gridTradeService = new OkxGridTradeService(config, accountName); |
| | | gridTradeService.startGrid(); |
| | | |
| | | wsKlineClient = new OkxKlineWebSocketClient(config.getWsKlineUrl()); |
| | | wsKlineClient.addChannelHandler(new OkxCandlestickChannelHandler(config.getContract(), gridTradeService)); |
| | | wsKlineClient.init(); |
| | | log.info("[管理器] K线WS已连接, 已注册K线频道处理器"); |
| | | |
| | | wsPrivateClient = new OkxKlineWebSocketClient( |
| | | config.getWsPrivateUrl(), |
| | | config.getApiKey(), |
| | |
| | | wsPrivateClient.addChannelHandler(new OkxPositionsChannelHandler(config.getContract(), gridTradeService)); |
| | | wsPrivateClient.addChannelHandler(new OkxAccountChannelHandler()); |
| | | wsPrivateClient.addChannelHandler(new OkxOrderInfoChannelHandler(config.getContract(), gridTradeService, config)); |
| | | wsPrivateClient.init(); |
| | | log.info("[管理器] 私有WS已连接, 已注册 3 个频道处理器"); |
| | | |
| | | wsPrivateClient.setOnLoginSuccess(() -> { |
| | | log.info("[管理器] 私有WS登录完成,启动K线订阅"); |
| | | try { |
| | | wsKlineClient = new OkxKlineWebSocketClient(config.getWsKlineUrl()); |
| | | wsKlineClient.addChannelHandler(new OkxCandlestickChannelHandler(config.getContract(), gridTradeService)); |
| | | wsKlineClient.init(); |
| | | log.info("[管理器] K线WS已连接, 已注册K线频道处理器"); |
| | | } catch (Exception e) { |
| | | log.error("[管理器] K线WS初始化失败", e); |
| | | } |
| | | }); |
| | | |
| | | wsPrivateClient.init(); |
| | | gridTradeService.setWebSocketClient(wsPrivateClient.getWebSocketClient()); |
| | | log.info("[管理器] 私有WS已连接, 等待登录完成..."); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("[管理器] 初始化失败", e); |