From 39119e045e77c693d1231948141d38c2c726c312 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 06 Aug 2026 16:01:30 +0800
Subject: [PATCH] fix(gate): 修复网格交易止损计数和同网格重复触发问题
---
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java | 11 +++++------
1 files changed, 5 insertions(+), 6 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 3b11a6d..5e271ec 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);
}
@@ -1287,7 +1287,6 @@
}
lastLongStopLossGridId = gridId;
- accumulatedLongLossCount++;
log.info("[Gate] 多仓止损触发 gridId:{}, 止损次数:{}{}, 开始追单",
gridId, accumulatedLongLossCount, sameGrid ? "(同网格)" : "");
int newEntryGridId = gridId + 1;
@@ -1330,6 +1329,7 @@
* </ul>
*/
private static final Map<Integer, int[]> STOP_LOSS_RULES = new LinkedHashMap<>();
+ private static final int DEFAULT_STOP_LOSS_PERCENT = 5;
static {
// times {满仓%, 阈值%}
@@ -1406,7 +1406,7 @@
int selfPos = Math.max(queryPositionSize(Position.ModeEnum.DUAL_LONG), longPositionSize.intValue());
int excess = selfPos - thresholdPosNum;
if (excess > 0) {
- int perOrderQty = maxPos * 5 / 100;
+ int perOrderQty = maxPos * DEFAULT_STOP_LOSS_PERCENT / 100;
if (perOrderQty <= 0) {
perOrderQty = 1;
}
@@ -1462,7 +1462,7 @@
int selfPos = Math.max(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue());
int excess = selfPos - thresholdPosNum;
if (excess > 0) {
- int perOrderQty = maxPos * 5 / 100;
+ int perOrderQty = maxPos * DEFAULT_STOP_LOSS_PERCENT / 100;
if (perOrderQty <= 0) {
perOrderQty = 1;
}
@@ -1496,7 +1496,6 @@
return;
}
lastShortStopLossGridId = gridId;
- accumulatedShortLossCount++;
log.info("[Gate] 空仓止损触发 gridId:{}, 止损次数:{}{}, 开始追单",
gridId, accumulatedShortLossCount, sameGrid ? "(同网格)" : "");
int newEntryGridId = gridId - 1;
--
Gitblit v1.9.1