From a4f609f251adfc5d196aeade70e2fce1b1e6b2da Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 24 Nov 2026 11:23:46 +0800
Subject: [PATCH] fix(gateApi): 忽略Gate配置反序列化未知属性
---
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java | 40 ++++++++++++++--------------------------
1 files changed, 14 insertions(+), 26 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 c5f7f64..f4dae9a 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -181,10 +181,6 @@
private final Map<String, Integer> tpReplenishLongOrderMap = new ConcurrentHashMap<>();
/** 仓位止盈补仓:空仓止盈→空仓开仓单ID → 张数(成交后按原空仓止损位重挂全持仓止损) */
private final Map<String, Integer> tpReplenishShortOrderMap = new ConcurrentHashMap<>();
- /** 原始仓位减仓:本轮多头是否已发生首次止损(startGrid 重置) */
- private volatile boolean longHasStopped = false;
- /** 原始仓位减仓:本轮空头是否已发生首次止损(startGrid 重置) */
- private volatile boolean shortHasStopped = false;
/** 原始仓位减仓:当前多头递减追单数量(价格驱动移动时保持) */
private volatile int currentLongChaseQty = 0;
/** 原始仓位减仓:当前空头递减追单数量(价格驱动移动时保持) */
@@ -461,8 +457,6 @@
dualStopLossModeActive.set(false);
tpReplenishLongOrderMap.clear();
tpReplenishShortOrderMap.clear();
- longHasStopped = false;
- shortHasStopped = false;
currentLongChaseQty = 0;
currentShortChaseQty = 0;
reduceReplenishLongOrderMap.clear();
@@ -2944,23 +2938,12 @@
/**
* 计算原始仓位减仓模式下的递减追单数量。
- * 本轮首次止损 → 追单 = 原始仓位;之后 → 追单 = 本次被平数量 - 步长;
+ * 每次止损(含首次)→ 追单 = 本次被平数量 - 步长;
* 若结果 < 步长 → 重置为原始仓位(最大仓位),形成循环。
*/
- private int computeReducedChaseQty(boolean isLong, int stoppedQty) {
+ private int computeReducedChaseQty(int stoppedQty) {
int baseQty = Integer.parseInt(config.getBaseQuantity());
int reduceStep = config.getOriginalPositionReduce();
- if (isLong) {
- if (!longHasStopped) {
- longHasStopped = true;
- return baseQty;
- }
- } else {
- if (!shortHasStopped) {
- shortHasStopped = true;
- return baseQty;
- }
- }
int chase = stoppedQty - reduceStep;
if (chase < reduceStep) {
chase = baseQty;
@@ -3120,8 +3103,8 @@
String size;
boolean hasAdd;
if (config.getOriginalPositionReduce() > 0) {
- // 原始仓位减仓:递减追单(首次=原始仓位,之后=本次被平数量-步长,≤步长时重置为原始仓位)
- int chaseQty = computeReducedChaseQty(true, gridStopLossSize);
+ // 原始仓位减仓:每次止损(含首次)按 本次被平数量-步长 递减,<步长时重置为原始仓位
+ int chaseQty = computeReducedChaseQty(gridStopLossSize);
currentLongChaseQty = chaseQty;
size = String.valueOf(chaseQty);
hasAdd = false;
@@ -3204,7 +3187,7 @@
String size;
boolean hasAdd;
if (config.getOriginalPositionReduce() > 0) {
- int chaseQty = computeReducedChaseQty(false, gridStopLossSize);
+ int chaseQty = computeReducedChaseQty(gridStopLossSize);
currentShortChaseQty = chaseQty;
size = String.valueOf(chaseQty);
hasAdd = false;
@@ -3472,8 +3455,11 @@
}
// 单位置全量止损:当前方向全部持仓挂一张止损单(入场格下方第2格,价格≤触发价平多)。
- // 取 max 是为了在 REST 时序竞态导致 filledQty 偏小时,至少保住 baseQuantity 的基础仓位
- int slSize = Math.max(filledQty, Integer.parseInt(config.getBaseQuantity()));
+ // 原始仓位减仓模式:止损必须严格等于实际持仓,否则下次止损的“被平数量”会被撑回 baseQuantity,
+ // 导致递减卡死(base-step 后不再继续递减);非减仓模式才用 max(filledQty, baseQuantity) 兜底。
+ int slSize = config.getOriginalPositionReduce() > 0
+ ? filledQty
+ : Math.max(filledQty, Integer.parseInt(config.getBaseQuantity()));
AtomicInteger remainCount = new AtomicInteger(1);
int sgId = gridId - 2;
placeStopLossOrders(sgId, 1, String.valueOf(slSize), FuturesPriceTrigger.RuleEnum.NUMBER_2,
@@ -3496,8 +3482,10 @@
}
// 单位置全量止损:当前方向全部持仓挂一张止损单(入场格上方第2格,价格≥触发价平空)。
- // 取 max 是为了在 REST 时序竞态导致 filledQty 偏小时,至少保住 baseQuantity 的基础仓位
- int slSize = Math.max(filledQty, Integer.parseInt(config.getBaseQuantity()));
+ // 原始仓位减仓模式:止损必须严格等于实际持仓,避免递减卡死;非减仓模式才用 max 兜底。
+ int slSize = config.getOriginalPositionReduce() > 0
+ ? filledQty
+ : Math.max(filledQty, Integer.parseInt(config.getBaseQuantity()));
AtomicInteger remainCount = new AtomicInteger(1);
int sgId = gridId + 2;
placeStopLossOrders(sgId, 1, String.valueOf(slSize), FuturesPriceTrigger.RuleEnum.NUMBER_1,
--
Gitblit v1.9.1