Administrator
2026-10-30 deb6521e256ea378e5f07fad3f4884674700126c
feat(station): 添加仓位止盈补仓开关功能

- 在前端面板新增仓位止盈补仓开关配置项及提示
- 在数据库策略状态表新增仓位止盈补仓字段及升级脚本
- 在后端策略状态实体类中添加对应属性及注释说明
- 在服务层实现类中补充新参数的解析与赋值逻辑
4 files modified
15 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java 1 ●●●●● patch | view | raw | blame | history
src/main/resources/db/station-schema.sql 9 ●●●●● patch | view | raw | blame | history
src/main/resources/static/station-dashboard.html 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java
@@ -91,6 +91,9 @@
    /** 对向加仓挂单数量 */
    private Integer tpTriggerOppositeAddQuantity;
    /** 仓位止盈补仓开关:true=止盈触发时在对侧止损位挂同方向同张数开仓单,false=保持现有逻辑 */
    private Boolean tpPositionReplenishEnabled;
    /** 单格止盈张数(基础仓位止盈:每个网格挂的止盈张数,支持小数) */
    private String baseTakeProfitPerGrid;
src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java
@@ -297,6 +297,7 @@
        if (params.containsKey("shortStopLossPrice")) status.setShortStopLossPrice(str(params.get("shortStopLossPrice")));
        if (params.containsKey("tpTriggerOppositeAddEnabled")) status.setTpTriggerOppositeAddEnabled(boolVal(params.get("tpTriggerOppositeAddEnabled")));
        if (params.containsKey("tpTriggerOppositeAddQuantity")) status.setTpTriggerOppositeAddQuantity(intVal(params.get("tpTriggerOppositeAddQuantity")));
        if (params.containsKey("tpPositionReplenishEnabled")) status.setTpPositionReplenishEnabled(boolVal(params.get("tpPositionReplenishEnabled")));
        if (params.containsKey("baseTakeProfitPerGrid")) status.setBaseTakeProfitPerGrid(str(params.get("baseTakeProfitPerGrid")));
        if (params.containsKey("baseTakeProfitGridCount")) status.setBaseTakeProfitGridCount(intVal(params.get("baseTakeProfitGridCount")));
        if (params.containsKey("rounds")) status.setTotalRounds(intVal(params.get("rounds")));
src/main/resources/db/station-schema.sql
@@ -29,6 +29,7 @@
    `short_stop_loss_price`      VARCHAR(32)  DEFAULT NULL COMMENT '空头止损触发价',
    `tp_trigger_opposite_add_enabled`  TINYINT(1) DEFAULT 0 COMMENT '止盈成交触发对向加仓开关',
    `tp_trigger_opposite_add_quantity` INT(11)   DEFAULT 0 COMMENT '对向加仓挂单数量',
    `tp_position_replenish_enabled`    TINYINT(1) DEFAULT 0 COMMENT '仓位止盈补仓开关',
    `base_take_profit_per_grid`        VARCHAR(32) DEFAULT NULL COMMENT '单格止盈张数(基础仓位止盈,支持小数)',
    `base_take_profit_grid_count`      INT(11)   DEFAULT 0 COMMENT '止盈网格数量(基础仓位止盈)',
    `current_round`  INT(11)      DEFAULT 0  COMMENT '当前轮次',
@@ -118,6 +119,14 @@
    ADD COLUMN `base_take_profit_grid_count` INT(11) DEFAULT 0 COMMENT '止盈网格数量(基础仓位止盈)' AFTER `base_take_profit_per_grid`;
-- ============================================================
-- 升级脚本:仓位止盈补仓开关(2026-10 新增)
-- 开启:任意方向止盈触发时,在对侧止损位挂相同张数、与止盈方向一致的开仓单(补回仓位);
-- 关闭:保持现有逻辑不变
-- ============================================================
ALTER TABLE `strategy_status`
    ADD COLUMN `tp_position_replenish_enabled` TINYINT(1) DEFAULT 0 COMMENT '仓位止盈补仓开关' AFTER `tp_trigger_opposite_add_quantity`;
-- ============================================================
-- 升级脚本:加仓停止阈值(2026-10 新增)
-- 与加仓启动阈值配合:启动阈值控制从第几次止损开始加仓,
-- 停止阈值控制启动后的最大加仓次数,超过后加仓张数恢复为基础张数;0=不限制
src/main/resources/static/station-dashboard.html
@@ -1097,6 +1097,7 @@
    shortStopLossPrice: '',
    tpTriggerOppositeAddEnabled: false,
    tpTriggerOppositeAddQuantity: 0,
    tpPositionReplenishEnabled: false,
    baseTakeProfitPerGrid: 0,
    baseTakeProfitGridCount: 0,
};
@@ -1146,6 +1147,7 @@
    { key: 'addPositionStopThreshold', label: '加仓停止阈值 (次)', type: 'number', placeholder: '0', jtype: 'int', group: 'addon', tip: '启动加仓后累计次数超过该值时,加仓张数恢复为基础张数;0 = 不限制' },
    { key: 'tpTriggerOppositeAddEnabled', label: '止盈触发对向加仓', type: 'select', options: [{ v: 'false', l: '关闭' }, { v: 'true', l: '开启' }], group: 'addon', tip: '止盈单成交后触发对向加仓' },
    { key: 'tpTriggerOppositeAddQuantity', label: '对向加仓挂单数量 (张)', type: 'number', placeholder: '0', jtype: 'int', group: 'addon', tip: '止盈成交后在对向挂出的加仓张数' },
    { key: 'tpPositionReplenishEnabled', label: '仓位止盈补仓', type: 'select', options: [{ v: 'false', l: '关闭' }, { v: 'true', l: '开启' }], group: 'addon', tip: '开启后:任意方向止盈触发时,在对侧止损位挂相同张数、与止盈方向一致的开仓单(补回仓位);关闭:保持现有逻辑' },
    { key: 'rounds', label: '运行轮数 (0=不限)', type: 'number', placeholder: '0', jtype: 'int', group: 'run', tip: '盈利重启达此轮数后停止' },
    { key: 'placeExcessTakeProfit', label: '止盈模式', type: 'select', options: [{ v: 'off', l: '关闭' }, { v: 'concentrated', l: '集中止盈' }, { v: 'dispersed', l: '分散止盈' }], group: 'run', tip: '超出基础仓位的加仓部分如何挂止盈' },