From ec9954eda0e8fe210beaa3b60f49eb9abdd021c4 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 23 Nov 2026 10:24:57 +0800
Subject: [PATCH] feat(config): 添加原始仓位减仓递减步长配置

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java |   45 +++++++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
index 6bc4530..9c9162c 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
@@ -142,10 +142,12 @@
     private final boolean tpTriggerOppositeAddEnabled;
     /** 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数,0=不启用。默认 0 */
     private final int tpTriggerOppositeAddQuantity;
-    /** 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数,支持小数。默认 0 */
-    private final BigDecimal baseTakeProfitPerGrid;
-    /** 止盈网格数量:基础仓位止盈挂单的网格数量。默认 0 */
-    private final int baseTakeProfitGridCount;
+    /** 仓位止盈补仓开关:true=止盈触发时在对侧止损位挂同方向同张数开仓单,false=保持现有逻辑。默认 false */
+    private final boolean tpPositionReplenishEnabled;
+    /** 原始仓位止盈总数量:平均分配到对手盘止损位前的所有网格,余数挂最后一格,每格至少1张。默认 0 */
+    private final int baseTakeProfitTotalQty;
+    /** 原始仓位减仓递减步长:0=关闭,>0=每次止损后追单量递减的步长,默认 0 */
+    private final int originalPositionReduce;
     /** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */
     private BigDecimal step;
     /** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */
@@ -193,8 +195,9 @@
         this.shortStopLossPrice = builder.shortStopLossPrice;
         this.tpTriggerOppositeAddEnabled = builder.tpTriggerOppositeAddEnabled;
         this.tpTriggerOppositeAddQuantity = builder.tpTriggerOppositeAddQuantity;
-        this.baseTakeProfitPerGrid = builder.baseTakeProfitPerGrid;
-        this.baseTakeProfitGridCount = builder.baseTakeProfitGridCount;
+        this.tpPositionReplenishEnabled = builder.tpPositionReplenishEnabled;
+        this.baseTakeProfitTotalQty = builder.baseTakeProfitTotalQty;
+        this.originalPositionReduce = builder.originalPositionReduce;
     }
 
     // ==================== REST/WS 地址 ====================
@@ -314,10 +317,12 @@
     public boolean isTpTriggerOppositeAddEnabled() { return tpTriggerOppositeAddEnabled; }
     /** @return 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数 */
     public int getTpTriggerOppositeAddQuantity() { return tpTriggerOppositeAddQuantity; }
-    /** @return 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数 */
-    public BigDecimal getBaseTakeProfitPerGrid() { return baseTakeProfitPerGrid; }
-    /** @return 止盈网格数量:基础仓位止盈挂单的网格数量 */
-    public int getBaseTakeProfitGridCount() { return baseTakeProfitGridCount; }
+    /** @return 仓位止盈补仓开关:true=止盈触发时在对侧止损位挂同方向同张数开仓单 */
+    public boolean isTpPositionReplenishEnabled() { return tpPositionReplenishEnabled; }
+    /** @return 原始仓位止盈总数量:平均分配到对手盘止损位前的所有网格 */
+    public int getBaseTakeProfitTotalQty() { return baseTakeProfitTotalQty; }
+    /** @return 原始仓位减仓递减步长:0=关闭,>0=每次止损后追单量递减的步长 */
+    public int getOriginalPositionReduce() { return originalPositionReduce; }
 
     // ==================== 运行时参数 ====================
 
@@ -442,10 +447,12 @@
         private boolean tpTriggerOppositeAddEnabled = false;
         /** 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数,默认 0 */
         private int tpTriggerOppositeAddQuantity = 0;
-        /** 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数,默认 0 */
-        private BigDecimal baseTakeProfitPerGrid = BigDecimal.ZERO;
-        /** 止盈网格数量:基础仓位止盈挂单的网格数量,默认 0 */
-        private int baseTakeProfitGridCount = 0;
+        /** 仓位止盈补仓开关:true=止盈触发时在对侧止损位挂同方向同张数开仓单。默认 false */
+        private boolean tpPositionReplenishEnabled = false;
+        /** 原始仓位止盈总数量:平均分配到对手盘止损位前的所有网格,默认 0 */
+        private int baseTakeProfitTotalQty = 0;
+        /** 原始仓位减仓递减步长:0=关闭,>0=每次止损后追单量递减的步长,默认 0 */
+        private int originalPositionReduce = 0;
 
         /** 设置 API Key */
         public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; }
@@ -521,10 +528,12 @@
         public Builder tpTriggerOppositeAddEnabled(boolean tpTriggerOppositeAddEnabled) { this.tpTriggerOppositeAddEnabled = tpTriggerOppositeAddEnabled; return this; }
         /** 设置对向加仓挂单数量:止盈成交后在对向挂出的开仓张数 */
         public Builder tpTriggerOppositeAddQuantity(int tpTriggerOppositeAddQuantity) { this.tpTriggerOppositeAddQuantity = tpTriggerOppositeAddQuantity; return this; }
-        /** 设置单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数 */
-        public Builder baseTakeProfitPerGrid(BigDecimal baseTakeProfitPerGrid) { this.baseTakeProfitPerGrid = baseTakeProfitPerGrid; return this; }
-        /** 设置止盈网格数量:基础仓位止盈挂单的网格数量 */
-        public Builder baseTakeProfitGridCount(int baseTakeProfitGridCount) { this.baseTakeProfitGridCount = baseTakeProfitGridCount; return this; }
+        /** 设置仓位止盈补仓开关:true=启用,false=禁用 */
+        public Builder tpPositionReplenishEnabled(boolean tpPositionReplenishEnabled) { this.tpPositionReplenishEnabled = tpPositionReplenishEnabled; return this; }
+        /** 设置原始仓位止盈总数量:平均分配到对手盘止损位前的所有网格 */
+        public Builder baseTakeProfitTotalQty(int baseTakeProfitTotalQty) { this.baseTakeProfitTotalQty = baseTakeProfitTotalQty; return this; }
+        /** 设置原始仓位减仓递减步长:0=关闭,>0=每次止损后追单量递减的步长 */
+        public Builder originalPositionReduce(int originalPositionReduce) { this.originalPositionReduce = originalPositionReduce; return this; }
 
         public GateConfig build() {
             return new GateConfig(this);

--
Gitblit v1.9.1