From d213ab840e7da86e1bc35037aaa3a844ef068793 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 27 Jul 2026 10:22:31 +0800
Subject: [PATCH] fix(gateApi): 修复网格交易中的止盈逻辑和数量计算问题
---
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 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 4292f7c..5a4bb0b 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -620,23 +620,23 @@
return;
}
- // [Gate-需求1] 多仓止盈触发:清空止盈状态 + 取消最近多仓止损
- GridElement longTpElem = GridElement.findByLongTakeProfitOrderId(orderId);
- if (longTpElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- longTakeProfitTraderIdParam(longTpElem, null, false);
-// log.info("[Gate] 多仓止盈触发 gridId:{}, orderId:{}", longTpElem.getId(), orderId);
-// cancelNearestLongStopLoss();
- return;
- }
- // [Gate-需求1] 空仓止盈触发:清空止盈状态 + 取消最近空仓止损
- GridElement shortTpElem = GridElement.findByShortTakeProfitOrderId(orderId);
- if (shortTpElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- shortTakeProfitTraderIdParam(shortTpElem, null, false);
-// log.info("[Gate] 空仓止盈触发 gridId:{}, orderId:{}", shortTpElem.getId(), orderId);
-// cancelNearestShortStopLoss();
-// checkLastTakeProfitAndRestart();
- return;
- }
+// // [Gate-需求1] 多仓止盈触发:清空止盈状态 + 取消最近多仓止损
+// GridElement longTpElem = GridElement.findByLongTakeProfitOrderId(orderId);
+// if (longTpElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
+// longTakeProfitTraderIdParam(longTpElem, null, false);
+//// log.info("[Gate] 多仓止盈触发 gridId:{}, orderId:{}", longTpElem.getId(), orderId);
+//// cancelNearestLongStopLoss();
+// return;
+// }
+// // [Gate-需求1] 空仓止盈触发:清空止盈状态 + 取消最近空仓止损
+// GridElement shortTpElem = GridElement.findByShortTakeProfitOrderId(orderId);
+// if (shortTpElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
+// shortTakeProfitTraderIdParam(shortTpElem, null, false);
+//// log.info("[Gate] 空仓止盈触发 gridId:{}, orderId:{}", shortTpElem.getId(), orderId);
+//// cancelNearestShortStopLoss();
+//// checkLastTakeProfitAndRestart();
+// return;
+// }
GridElement longStopLossElem = GridElement.findByLongStopLossOrderId(orderId);
// if (longStopLossElem != null && longPositionSize.compareTo(BigDecimal.ZERO) > 0 && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
@@ -1255,7 +1255,7 @@
if (newEntryGrid != null) {
// String quantity = String.valueOf((accumulatedLongLossCount + 1) * Integer.parseInt(config.getQuantity()));
- String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue()) + 1);
+ String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue()) + Integer.parseInt(config.getQuantity()));
// 向上遍历取消所有遗留多单(跳过基础入场网格0)
GridElement cancelCursor = GridElement.findById(newEntryGrid.getUpId());
while (cancelCursor != null) {
@@ -1311,7 +1311,7 @@
if (newEntryGrid != null) {
// String quantity = String.valueOf((accumulatedShortLossCount + 1) * Integer.parseInt(config.getQuantity()));
- String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_LONG), longPositionSize.intValue()) + 1);
+ String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_LONG), longPositionSize.intValue()) + Integer.parseInt(config.getQuantity()));
// 向下遍历取消所有遗留空单(跳过基础入场网格0)
GridElement cancelCursor = GridElement.findById(newEntryGrid.getDownId());
while (cancelCursor != null) {
--
Gitblit v1.9.1