From bb0263cbffa0d282ea60a6d24647f78d6b7bcb9d Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 12 Aug 2026 10:21:35 +0800
Subject: [PATCH] feat(gate): 添加超额止盈功能配置选项
---
src/main/resources/static/gate-config.html | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/static/gate-config.html b/src/main/resources/static/gate-config.html
index 1b41299..7c3d40e 100644
--- a/src/main/resources/static/gate-config.html
+++ b/src/main/resources/static/gate-config.html
@@ -117,6 +117,22 @@
<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>
+ <div class="form-group"><label>超额止盈开关</label><select id="placeExcessTakeProfit"><option value="false" selected>关闭</option><option value="true">开启</option></select></div>
</form>
</div>
@@ -192,7 +208,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, placeExcessTakeProfit: false });
toast('未找到配置,已加载默认值,编辑后请保存', 'success');
}
currentApiKey = key;
@@ -212,6 +229,12 @@
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;
+ byId('placeExcessTakeProfit').value = (d.placeExcessTakeProfit === true || d.placeExcessTakeProfit === 'true') ? 'true' : 'false';
}
function collectForm() {
@@ -226,9 +249,19 @@
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: intVal(byId('addPositionInterval').value, 3),
+ addPositionQuantity: intVal(byId('addPositionQuantity').value, 1),
+ maxPositionPerSide: intVal(byId('maxPositionPerSide').value, 0),
+ addPositionStartThreshold: intVal(byId('addPositionStartThreshold').value, 1),
+ placeExcessTakeProfit: byId('placeExcessTakeProfit').value === 'true'
};
}
+function intVal(str, fallback) {
+ const v = parseInt(str);
+ return isNaN(v) ? fallback : v;
+}
async function saveConfig() {
if (!currentApiKey) return toast('请先输入 API Key', 'error');
--
Gitblit v1.9.1