From 6d2c1838edb17459daad0a37806b8ac30700a0e2 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 21 May 2026 10:18:39 +0800
Subject: [PATCH] fix(gateApi): 解决网格交易策略停止时的订单清理和日志优化
---
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
index 4fd0216..4b3a869 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -342,6 +342,16 @@
lastKlinePrice = closePrice;
updateUnrealizedPnl();
if (state == StrategyState.STOPPED) {
+ try {
+ futuresApi.cancelPriceTriggeredOrderList(SETTLE, config.getContract());
+ } catch (ApiException e) {
+ e.printStackTrace();
+ }
+ closeExistingPositions();
+
+ BigDecimal totalPnl = cumulativePnl.add(unrealizedPnl);
+ log.info("[Gate] 已实现:{}, 未实现:{}, 合计:{}",
+ cumulativePnl, unrealizedPnl, totalPnl);
return;
}
@@ -518,8 +528,8 @@
}
cumulativePnl = cumulativePnl.add(pnl);
BigDecimal totalPnl = cumulativePnl.add(unrealizedPnl);
- log.info("[Gate] 盈亏累加:{}, 方向:{}, 已实现:{}, 未实现:{}, 合计:{}",
- pnl, side, cumulativePnl, unrealizedPnl, totalPnl);
+ log.info("[Gate] 已实现:{}, 未实现:{}, 合计:{}",
+ cumulativePnl, unrealizedPnl, totalPnl);
if (totalPnl.compareTo(config.getOverallTp()) >= 0) {
log.info("[Gate] 已达止盈目标(合计{})→已停止, 已实现:{}, 未实现:{}",
--
Gitblit v1.9.1