From eacf8474863750241bbed99e8c04d57b9fe42b1c Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 25 Jun 2026 14:45:03 +0800
Subject: [PATCH] refactor(gateApi): 止盈都严格保持 2 个 grid 间距

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java |   39 ++++++++-------------------------------
 1 files changed, 8 insertions(+), 31 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 ec5f544..e0e1de7 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;
 
@@ -60,17 +58,18 @@
         try {
             //实盘
             config = GateConfig.builder()
-                    .apiKey("08d6108fc29378fe64d6f0e89745b3fb")
-                    .apiSecret("4d16e40117477a2344f6fd5872c5b075dc9664a599e65422d3e6791ff64379f1")
+                    .apiKey("a2338398e00b7935104520e16be96918")
+                    .apiSecret("9111d897f2346d5217619f2da76536632715fef4d7eb304c6c61e869a2a74e98")
                     .contract("ETH_USDT")
                     .leverage("100")
                     .marginMode("CROSS")
                     .positionMode("dual")
-                    .gridRate(new BigDecimal("0.0025"))
-                    .expectedProfit(new BigDecimal("0.05"))
+                    .gridRate(new BigDecimal("0.0035"))
+                    .expectedProfit(new BigDecimal("2.5"))
                     .maxLoss(new BigDecimal("1.5"))
-                    .baseQuantity("1")
-                    .quantity("1")
+                    .baseQuantity("9")
+                    .quantity("3")
+                    .restartGridSpan(2)
                     .maxPositionSize(2)
                     .priceScale(2)
                     .contractMultiplier(new BigDecimal("0.01"))
@@ -78,24 +77,6 @@
                     .isProduction(true)
                     .reopenMaxRetries(3)
                     .build();
-//            //测试盘
-//            config = GateConfig.builder()
-//                    .apiKey("d90ca272391992b8e74f8f92cedb21ec")
-//                    .apiSecret("1861e4f52de4bb53369ea3208d9ede38ece4777368030f96c77d27934c46c274")
-//                    .contract("ETH_USDT")
-//                    .leverage("100")
-//                    .marginMode("CROSS")
-//                    .positionMode("dual")
-//                    .gridRate(new BigDecimal("0.002"))
-//                    .expectedProfit(new BigDecimal("1"))
-//                    .maxLoss(new BigDecimal("15"))
-//                    .quantity("1")
-//                    .priceScale(1)
-//                    .contractMultiplier(new BigDecimal("0.01"))
-//                    .unrealizedPnlPriceMode(GateConfig.PnLPriceMode.LAST_PRICE)
-//                    .isProduction(false)
-//                    .reopenMaxRetries(3)
-//                    .build();
 
             // 1. 初始化交易服务:查用户ID → 切持仓模式 → 清条件单 → 平已有仓位 → 设杠杆
             gridTradeService = new GateGridTradeService(config);
@@ -108,15 +89,11 @@
                     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