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/GateGridTradeService.java |   11 ++---------
 1 files changed, 2 insertions(+), 9 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 1ea2c85..7e458a9 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -650,10 +650,7 @@
                     BigDecimal shortExcess = BigDecimal.valueOf(posSize).subtract(shortBaseQty);
                     int shortExcessCount = shortExcess.divide(shortGridQty, 0, RoundingMode.DOWN).intValue();
                     for (int i = 0; i < shortExcessCount; i++) {
-                        int tpGridId = shortGridElement.getId() - 2 - i;
-                        if (i > 0){
-                            tpGridId = tpGridId - 1;
-                        }
+                        int tpGridId = shortGridElement.getId() - 2 * (i + 1);
                         GridElement tpElem = GridElement.findById(tpGridId);
                         if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) {
                             continue;
@@ -695,11 +692,7 @@
                     BigDecimal longExcess = BigDecimal.valueOf(posSize).subtract(longBaseQty);
                     int longExcessCount = longExcess.divide(longGridQty, 0, RoundingMode.DOWN).intValue();
                     for (int i = 0; i < longExcessCount; i++) {
-                        int tpGridId = longGridElement.getId() + 2 + i;
-                        if (i > 0){
-                            tpGridId = tpGridId + 1;
-                        }
-
+                        int tpGridId = longGridElement.getId() + 2 * (i + 1);
                         GridElement tpElem = GridElement.findById(tpGridId);
                         if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) {
                             continue;

--
Gitblit v1.9.1