From 8a18b4228cdba52ba481ce6528de4ae981682dea Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 09 Oct 2026 10:14:12 +0800
Subject: [PATCH] fix(gateApi): 修正网格交易止盈逻辑

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 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 fa96fd5..fa70691 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
@@ -136,6 +136,14 @@
     private final BigDecimal longStopLossPrice;
     /** 空仓自定义止损触发价(价格涨至该值触发平空),null/0=未设置 */
     private final BigDecimal shortStopLossPrice;
+    /** 止盈成交触发对向加仓开关:true=启用,false=禁用。默认 false */
+    private final boolean tpTriggerOppositeAddEnabled;
+    /** 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数,0=不启用。默认 0 */
+    private final int tpTriggerOppositeAddQuantity;
+    /** 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数,支持小数。默认 0 */
+    private final BigDecimal baseTakeProfitPerGrid;
+    /** 止盈网格数量:基础仓位止盈挂单的网格数量。默认 0 */
+    private final int baseTakeProfitGridCount;
     /** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */
     private BigDecimal step;
     /** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */
@@ -180,6 +188,10 @@
         this.dualStopLossEnabled = builder.dualStopLossEnabled;
         this.longStopLossPrice = builder.longStopLossPrice;
         this.shortStopLossPrice = builder.shortStopLossPrice;
+        this.tpTriggerOppositeAddEnabled = builder.tpTriggerOppositeAddEnabled;
+        this.tpTriggerOppositeAddQuantity = builder.tpTriggerOppositeAddQuantity;
+        this.baseTakeProfitPerGrid = builder.baseTakeProfitPerGrid;
+        this.baseTakeProfitGridCount = builder.baseTakeProfitGridCount;
     }
 
     // ==================== REST/WS 地址 ====================
@@ -293,6 +305,14 @@
     public BigDecimal getLongStopLossPrice() { return longStopLossPrice; }
     /** @return 空仓自定义止损触发价,null/0=未设置 */
     public BigDecimal getShortStopLossPrice() { return shortStopLossPrice; }
+    /** @return 止盈成交触发对向加仓开关:true=启用,false=禁用 */
+    public boolean isTpTriggerOppositeAddEnabled() { return tpTriggerOppositeAddEnabled; }
+    /** @return 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数 */
+    public int getTpTriggerOppositeAddQuantity() { return tpTriggerOppositeAddQuantity; }
+    /** @return 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数 */
+    public BigDecimal getBaseTakeProfitPerGrid() { return baseTakeProfitPerGrid; }
+    /** @return 止盈网格数量:基础仓位止盈挂单的网格数量 */
+    public int getBaseTakeProfitGridCount() { return baseTakeProfitGridCount; }
 
     // ==================== 运行时参数 ====================
 
@@ -411,6 +431,14 @@
         private BigDecimal longStopLossPrice;
         /** 空仓自定义止损触发价,null=未设置 */
         private BigDecimal shortStopLossPrice;
+        /** 止盈成交触发对向加仓开关:true=启用,false=禁用。默认 false */
+        private boolean tpTriggerOppositeAddEnabled = false;
+        /** 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数,默认 0 */
+        private int tpTriggerOppositeAddQuantity = 0;
+        /** 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数,默认 0 */
+        private BigDecimal baseTakeProfitPerGrid = BigDecimal.ZERO;
+        /** 止盈网格数量:基础仓位止盈挂单的网格数量,默认 0 */
+        private int baseTakeProfitGridCount = 0;
 
         /** 设置 API Key */
         public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; }
@@ -480,6 +508,14 @@
         public Builder longStopLossPrice(BigDecimal longStopLossPrice) { this.longStopLossPrice = longStopLossPrice; return this; }
         /** 设置空仓自定义止损触发价 */
         public Builder shortStopLossPrice(BigDecimal shortStopLossPrice) { this.shortStopLossPrice = shortStopLossPrice; return this; }
+        /** 设置止盈成交触发对向加仓开关:true=启用,false=禁用 */
+        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; }
 
         public GateConfig build() {
             return new GateConfig(this);

--
Gitblit v1.9.1