From 7491d19c0412712080f23c389eb2f1bfa2924e09 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 19 May 2026 11:37:10 +0800
Subject: [PATCH] ``` fix(gate): 修复网格交易中订单状态更新处理逻辑
---
src/main/java/com/xcong/excoin/modules/gateApi/GateWebSocketClientManager.java | 51 +++++++++++++++++++++++++++++----------------------
1 files changed, 29 insertions(+), 22 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 e21b897..def4b82 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,11 @@
package com.xcong.excoin.modules.gateApi;
+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;
@@ -50,39 +52,40 @@
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("d90ca272391992b8e74f8f92cedb21ec")
-// .apiSecret("1861e4f52de4bb53369ea3208d9ede38ece4777368030f96c77d27934c46c274")
+// .apiKey("865371cdaccd5d238aceb06a55f0143a")
+// .apiSecret("49589c30dfdc3acba007eed445a94990c4b0aa5faac9843e32defdd7371f5a50")
// .contract("ETH_USDT")
// .leverage("100")
// .marginMode("CROSS")
// .positionMode("dual")
-// .gridRate(new BigDecimal("0.003"))
+// .gridRate(new BigDecimal("0.005"))
// .overallTp(new BigDecimal("5"))
// .maxLoss(new BigDecimal("15"))
// .quantity("1")
// .contractMultiplier(new BigDecimal("0.01"))
// .unrealizedPnlPriceMode(GateConfig.PnLPriceMode.LAST_PRICE)
-// .isProduction(false)
+// .isProduction(true)
// .reopenMaxRetries(3)
// .build();
- //实盘
- config = GateConfig.builder()
- .apiKey("865371cdaccd5d238aceb06a55f0143a")
- .apiSecret("49589c30dfdc3acba007eed445a94990c4b0aa5faac9843e32defdd7371f5a50")
- .contract("ETH_USDT")
- .leverage("100")
- .marginMode("CROSS")
- .positionMode("dual")
- .gridRate(new BigDecimal("0.005"))
- .overallTp(new BigDecimal("5"))
- .maxLoss(new BigDecimal("15"))
- .quantity("1")
- .contractMultiplier(new BigDecimal("0.01"))
- .unrealizedPnlPriceMode(GateConfig.PnLPriceMode.LAST_PRICE)
- .isProduction(true)
- .reopenMaxRetries(3)
- .build();
// 1. 初始化交易服务:查用户ID → 切持仓模式 → 清条件单 → 平已有仓位 → 设杠杆
gridTradeService = new GateGridTradeService(config);
@@ -97,8 +100,12 @@
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));
wsClient.init();
- log.info("[管理器] WS已连接, 已注册 4 个频道处理器");
+ log.info("[管理器] WS已连接, 已注册 6 个频道处理器");
// 3. 激活策略,等待首根 K 线触发基底双开
gridTradeService.startGrid();
--
Gitblit v1.9.1