Administrator
2026-08-10 b10dfeebdf93728fdba36477467708006f72f993
src/main/resources/static/gate-config.html
@@ -117,6 +117,20 @@
            <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>
        </form>
    </div>
@@ -192,7 +206,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 });
        toast('未找到配置,已加载默认值,编辑后请保存', 'success');
    }
    currentApiKey = key;
@@ -212,6 +227,10 @@
    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;
}
function collectForm() {
@@ -226,7 +245,11 @@
        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
    };
}