From d0009bfa3e84e6a08e5b968d8a45619a0bf35441 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 10 Aug 2026 14:27:17 +0800
Subject: [PATCH] feat(gate): 添加加仓启动阈值配置功能

---
 src/main/resources/static/gate-config.html |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/static/gate-config.html b/src/main/resources/static/gate-config.html
index 1b41299..d86b442 100644
--- a/src/main/resources/static/gate-config.html
+++ b/src/main/resources/static/gate-config.html
@@ -117,6 +117,21 @@
             <div class="form-group"><label>止盈网格跨度</label><input id="takeProfitGridSpan" placeholder="2"></div>
             <div class="form-group"><label>价格驱动开关</label><select id="priceDriveEnabled"><option value="true" selected>开启</option><option value="false">关闭</option></select></div>
             <div class="form-group"><label>运行轮数(0=不限)</label><input id="rounds" type="number" placeholder="0"></div>
+            <!-- ===== 加仓止损配置 ===== -->
+            <div class="form-group full" style="margin-top:6px;border-top:1px solid var(--border);padding-top:8px">
+                <label style="font-size:13px;font-weight:600;color:var(--text)">加仓 & 止损统计</label>
+            </div>
+            <div class="form-group">
+                <label>止损次数统计方式</label>
+                <select id="stopLossCountMode">
+                    <option value="dual" selected>双向统一统计</option>
+                    <option value="single">单向分别统计</option>
+                </select>
+            </div>
+            <div class="form-group"><label>加仓间隔(次)</label><input id="addPositionInterval" type="number" placeholder="3"></div>
+            <div class="form-group"><label>加仓数量(张)</label><input id="addPositionQuantity" type="number" placeholder="1"></div>
+            <div class="form-group"><label>单边最大仓位量(张)</label><input id="maxPositionPerSide" type="number" placeholder="0(不限制)"></div>
+            <div class="form-group"><label>加仓启动阈值(次)</label><input id="addPositionStartThreshold" type="number" placeholder="1(前N次止损不加仓)"></div>
         </form>
     </div>
 
@@ -192,7 +207,8 @@
     } catch(e) {
         // 文件不存在 → 用默认值填充,用户可编辑后保存
         fillForm({ gridRate:0.005, expectedProfit:0.15, maxLoss:1.5,
-            baseQuantity:'2', quantity:'2', maxPositionSize:4, stopLossCount:0, takeProfitGridSpan:2, priceDriveEnabled: true, rounds: 0 });
+            baseQuantity:'2', quantity:'2', maxPositionSize:4, stopLossCount:0, takeProfitGridSpan:2, priceDriveEnabled: true, rounds: 0,
+            stopLossCountMode:'dual', addPositionInterval:3, addPositionQuantity:1, maxPositionPerSide:0, addPositionStartThreshold:1 });
         toast('未找到配置,已加载默认值,编辑后请保存', 'success');
     }
     currentApiKey = key;
@@ -212,6 +228,11 @@
     byId('takeProfitGridSpan').value = d.takeProfitGridSpan ?? '';
     byId('priceDriveEnabled').value = (d.priceDriveEnabled === true || d.priceDriveEnabled === 'true') ? 'true' : 'false';
     byId('rounds').value = d.rounds ?? 0;
+    byId('stopLossCountMode').value = d.stopLossCountMode || 'dual';
+    byId('addPositionInterval').value = d.addPositionInterval ?? 3;
+    byId('addPositionQuantity').value = d.addPositionQuantity ?? 1;
+    byId('maxPositionPerSide').value = d.maxPositionPerSide ?? 0;
+    byId('addPositionStartThreshold').value = d.addPositionStartThreshold ?? 1;
 }
 
 function collectForm() {
@@ -226,7 +247,12 @@
         stopLossCount: parseInt(byId('stopLossCount').value) || 0,
         takeProfitGridSpan: parseInt(byId('takeProfitGridSpan').value) || 2,
         priceDriveEnabled: byId('priceDriveEnabled').value === 'true',
-        rounds: parseInt(byId('rounds').value) || 0
+        rounds: parseInt(byId('rounds').value) || 0,
+        stopLossCountMode: byId('stopLossCountMode').value,
+        addPositionInterval: parseInt(byId('addPositionInterval').value) || 3,
+        addPositionQuantity: parseInt(byId('addPositionQuantity').value) || 1,
+        maxPositionPerSide: parseInt(byId('maxPositionPerSide').value) || 0,
+        addPositionStartThreshold: parseInt(byId('addPositionStartThreshold').value) ?? 1
     };
 }
 

--
Gitblit v1.9.1