Administrator
2026-09-20 42459e21c8be46ab877f7badcb9c4357b88b2341
src/main/resources/static/gate-config.html
@@ -133,6 +133,13 @@
            <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="off" selected>关闭</option><option value="concentrated">集中止盈</option><option value="dispersed">分散止盈</option></select></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="customStopLossEnabled"><option value="false" selected>关闭</option><option value="true">开启</option></select></div>
            <div class="form-group"><label>多仓止损触发价</label><input id="longCustomStopLossPrice" placeholder="如 2540(价格跌至触发平多)"></div>
            <div class="form-group"><label>空仓止损触发价</label><input id="shortCustomStopLossPrice" placeholder="如 2650(价格涨至触发平空)"></div>
        </form>
    </div>
@@ -209,7 +216,8 @@
        // 文件不存在 → 用默认值填充,用户可编辑后保存
        fillForm({ gridRate:0.005, expectedProfit:0.15, maxLoss:1.5,
            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: 'off' });
            stopLossCountMode:'dual', addPositionInterval:3, addPositionQuantity:1, maxPositionPerSide:0, addPositionStartThreshold:1, placeExcessTakeProfit: 'off',
            customStopLossEnabled: false, longCustomStopLossPrice: null, shortCustomStopLossPrice: null });
        toast('未找到配置,已加载默认值,编辑后请保存', 'success');
    }
    currentApiKey = key;
@@ -235,6 +243,9 @@
    byId('maxPositionPerSide').value = d.maxPositionPerSide ?? 0;
    byId('addPositionStartThreshold').value = d.addPositionStartThreshold ?? 1;
    byId('placeExcessTakeProfit').value = normalizeTpMode(d.placeExcessTakeProfit);
    byId('customStopLossEnabled').value = (d.customStopLossEnabled === true || d.customStopLossEnabled === 'true') ? 'true' : 'false';
    byId('longCustomStopLossPrice').value = d.longCustomStopLossPrice || '';
    byId('shortCustomStopLossPrice').value = d.shortCustomStopLossPrice || '';
}
function collectForm() {
@@ -255,7 +266,10 @@
        addPositionQuantity: intVal(byId('addPositionQuantity').value, 1),
        maxPositionPerSide: intVal(byId('maxPositionPerSide').value, 0),
        addPositionStartThreshold: intVal(byId('addPositionStartThreshold').value, 1),
        placeExcessTakeProfit: byId('placeExcessTakeProfit').value
        placeExcessTakeProfit: byId('placeExcessTakeProfit').value,
        customStopLossEnabled: byId('customStopLossEnabled').value === 'true',
        longCustomStopLossPrice: parseFloat(byId('longCustomStopLossPrice').value) || null,
        shortCustomStopLossPrice: parseFloat(byId('shortCustomStopLossPrice').value) || null
    };
}
function intVal(str, fallback) {