From 5c29bd9cc72880c9de59e69447e9eeafd53bf633 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 08 May 2026 12:45:45 +0800
Subject: [PATCH] feat(gateApi): 添加WebSocket频道处理器架构重构
---
src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java
index 63f478c..1d7af64 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java
@@ -1,9 +1,9 @@
package com.xcong.excoin.modules.gateApi;
-import com.xcong.excoin.modules.okxNewPrice.celue.CaoZuoService;
-import com.xcong.excoin.modules.okxNewPrice.okxWs.wanggeList.WangGeListService;
+import com.xcong.excoin.modules.gateApi.wsHandler.handler.CandlestickChannelHandler;
+import com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionClosesChannelHandler;
+import com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionsChannelHandler;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -41,10 +41,6 @@
@Slf4j
@Component
public class GateWebSocketClientManager {
- @Autowired
- private CaoZuoService caoZuoService;
- @Autowired
- private WangGeListService wangGeListService;
/** K 线 WebSocket 客户端 */
private GateKlineWebSocketClient klinePriceClient;
@@ -55,6 +51,8 @@
private static final String API_KEY = "d90ca272391992b8e74f8f92cedb21ec";
/** Gate 测试网 API Secret */
private static final String API_SECRET = "1861e4f52de4bb53369ea3208d9ede38ece4777368030f96c77d27934c46c274";
+ /** 合约 */
+ private static final String CONTRACT = "XAUT_USDT";
/**
* Spring 容器启动后自动调用。初始化网格交易服务和 WebSocket 客户端。
@@ -66,21 +64,23 @@
try {
gridTradeService = new GateGridTradeService(
API_KEY, API_SECRET,
- "XAUT_USDT",
+ CONTRACT,
"30",
"cross",
"dual",
new BigDecimal("0.0035"),
new BigDecimal("0.5"),
- 3,
new BigDecimal("7.5"),
"10"
);
gridTradeService.init();
- klinePriceClient = new GateKlineWebSocketClient(caoZuoService, this, wangGeListService, gridTradeService, API_KEY, API_SECRET);
+ klinePriceClient = new GateKlineWebSocketClient();
+ klinePriceClient.addChannelHandler(new CandlestickChannelHandler(CONTRACT, gridTradeService));
+ klinePriceClient.addChannelHandler(new PositionsChannelHandler(API_KEY, API_SECRET, CONTRACT, gridTradeService));
+ klinePriceClient.addChannelHandler(new PositionClosesChannelHandler(API_KEY, API_SECRET, CONTRACT, gridTradeService));
klinePriceClient.init();
- log.info("已初始化GateKlineWebSocketClient");
+ log.info("已初始化GateKlineWebSocketClient及3个频道Handler");
gridTradeService.startGrid();
} catch (Exception e) {
--
Gitblit v1.9.1