From 0324007d0ed8a40fc9c3b00181a41b3b2f6e1107 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 04 Aug 2026 21:25:17 +0800
Subject: [PATCH] fix(gateApi): 修复网格交易中订单数量计算逻辑

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 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 5ce118d..bef35fb 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -676,7 +676,7 @@
                 log.info("[Gate] 空单成交 gridId:{}, 当前持仓:{}张", filledQty, posSize);
 
 
-
+                accumulatedShortLossCount++;
                 checkShortStopLongProfit(accumulatedShortLossCount, shortGridElement.getId() + 2);
 
             }
@@ -708,7 +708,7 @@
 //                placeExcessTakeProfit(posSize, true);
                 log.info("[Gate] 多单成交 gridId:{}, 当前持仓:{}张", filledQty, posSize);
 
-
+                accumulatedLongLossCount++;
                 checkLongStopShortProfit(accumulatedLongLossCount, longGridElement.getId() -2);
 
             }
@@ -1157,8 +1157,8 @@
 
                     if (newEntryGrid != null) {
 
-                        String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue()) + Integer.parseInt(config.getQuantity()));
-
+//                        String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue()) + Integer.parseInt(config.getQuantity()));
+                        String quantity = String.valueOf(config.getBaseQuantity());
                         // 向下检查是否已有多单挂在更低价格网格,有则跳过(防止价格回升后重复挂单)
                         boolean hasLongOrderBelow = false;
                         GridElement checkDownCursor = GridElement.findById(newEntryGrid.getDownId());
@@ -1228,8 +1228,8 @@
                     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()) + Integer.parseInt(config.getQuantity()));
-
+//                        String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_LONG), longPositionSize.intValue()) + Integer.parseInt(config.getQuantity()));
+                        String quantity = String.valueOf(config.getBaseQuantity());
                         // 向上检查是否已有空单挂在更高价格网格,有则跳过(防止价格回落后重复挂单)
                         boolean hasShortOrderAbove = false;
                         GridElement checkUpCursor = GridElement.findById(newEntryGrid.getUpId());
@@ -1287,7 +1287,6 @@
         }
 
         lastLongStopLossGridId = gridId;
-        accumulatedLongLossCount++;
         log.info("[Gate] 多仓止损触发 gridId:{}, 止损次数:{}{}, 开始追单",
                 gridId, accumulatedLongLossCount, sameGrid ? "(同网格)" : "");
         int newEntryGridId = gridId + 1;
@@ -1497,7 +1496,6 @@
             return;
         }
         lastShortStopLossGridId = gridId;
-        accumulatedShortLossCount++;
         log.info("[Gate] 空仓止损触发 gridId:{}, 止损次数:{}{}, 开始追单",
                 gridId, accumulatedShortLossCount, sameGrid ? "(同网格)" : "");
         int newEntryGridId = gridId - 1;

--
Gitblit v1.9.1