From 44e5dbee83a22eaf5d94ca390ea373361623cb96 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 15 Jun 2026 15:24:27 +0800
Subject: [PATCH] refactor(gateApi): 修改网格交易止损扩展方法参数

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java |   39 +++++++++------------------------------
 1 files changed, 9 insertions(+), 30 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 ef58b29..519971d 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java
@@ -2,10 +2,8 @@
 
 import com.xcong.excoin.modules.gateApi.wsHandler.handler.AutoOrdersChannelHandler;
 import com.xcong.excoin.modules.gateApi.wsHandler.handler.CandlestickChannelHandler;
-import com.xcong.excoin.modules.gateApi.wsHandler.handler.OrdersChannelHandler;
 import com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionClosesChannelHandler;
 import com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionsChannelHandler;
-import com.xcong.excoin.modules.gateApi.wsHandler.handler.UserTradesChannelHandler;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
@@ -58,24 +56,6 @@
         log.info("[管理器] 开始初始化...");
 
         try {
-            //测试盘
-//            config = GateConfig.builder()
-//                    .apiKey("d90ca272391992b8e74f8f92cedb21ec")
-//                    .apiSecret("1861e4f52de4bb53369ea3208d9ede38ece4777368030f96c77d27934c46c274")
-//                    .contract("ETH_USDT")
-//                    .leverage("100")
-//                    .marginMode("CROSS")
-//                    .positionMode("dual")
-//                    .gridRate(new BigDecimal("0.002"))
-//                    .overallTp(new BigDecimal("5"))
-//                    .maxLoss(new BigDecimal("15"))
-//                    .quantity("1")
-//                    .priceScale(1)
-//                    .contractMultiplier(new BigDecimal("0.01"))
-//                    .unrealizedPnlPriceMode(GateConfig.PnLPriceMode.LAST_PRICE)
-//                    .isProduction(false)
-//                    .reopenMaxRetries(3)
-//                    .build();
             //实盘
             config = GateConfig.builder()
                     .apiKey("a2338398e00b7935104520e16be96918")
@@ -84,10 +64,12 @@
                     .leverage("100")
                     .marginMode("CROSS")
                     .positionMode("dual")
-                    .gridRate(new BigDecimal("0.005"))
-                    .overallTp(new BigDecimal("100"))
-                    .maxLoss(new BigDecimal("15"))
-                    .quantity("5")
+                    .gridRate(new BigDecimal("0.0025"))
+                    .expectedProfit(new BigDecimal("0.05"))
+                    .maxLoss(new BigDecimal("1.5"))
+                    .baseQuantity("1")
+                    .quantity("1")
+                    .maxPositionSize(2)
                     .priceScale(2)
                     .contractMultiplier(new BigDecimal("0.01"))
                     .unrealizedPnlPriceMode(GateConfig.PnLPriceMode.LAST_PRICE)
@@ -99,21 +81,18 @@
             gridTradeService = new GateGridTradeService(config);
             gridTradeService.init();
 
-            // 2. 创建 WS 客户端并注册 3 个频道处理器
+            // 2. 创建 WS 客户端并注册频道处理器
             wsClient = new GateKlineWebSocketClient(config.getWsUrl());
             wsClient.addChannelHandler(new CandlestickChannelHandler(config.getContract(), gridTradeService));
             wsClient.addChannelHandler(new PositionsChannelHandler(
                     config.getApiKey(), config.getApiSecret(), config.getContract(), gridTradeService));
             wsClient.addChannelHandler(new PositionClosesChannelHandler(
                     config.getApiKey(), config.getApiSecret(), config.getContract(), gridTradeService));
-            wsClient.addChannelHandler(new OrdersChannelHandler(
-                    config.getApiKey(), config.getApiSecret(), config.getContract(), gridTradeService));
-            wsClient.addChannelHandler(new UserTradesChannelHandler(
-                    config.getApiKey(), config.getApiSecret(), config.getContract(), gridTradeService));
             wsClient.addChannelHandler(new AutoOrdersChannelHandler(
                     config.getApiKey(), config.getApiSecret(), config.getContract(), gridTradeService));
+            gridTradeService.setWsClient(wsClient);
             wsClient.init();
-            log.info("[管理器] WS已连接, 已注册 6 个频道处理器");
+            log.info("[管理器] WS已连接, 已注册 4 个频道处理器");
 
             // 3. 激活策略,等待首根 K 线触发基底双开
             gridTradeService.startGrid();

--
Gitblit v1.9.1