feat(station): 扩展止盈模式配置功能
- 将止盈配置从布尔类型改为字符串类型,支持三种模式:关闭(off)、集中止盈(concentrated)、分散止盈(dispersed)
- 更新数据库表结构,修改place_excess_take_profit字段为VARCHAR(16),并保留原有数据转换逻辑
- 修改前端界面选项,将原来的开关选择改为下拉菜单选择三种止盈模式
- 更新后端服务实现,适配字符串类型的参数解析和存储逻辑
- 完善相关实体类字段定义和注释说明,明确各模式的具体含义和用途
| | |
| | | /** 加仓启动阈值 */ |
| | | private Integer addPositionStartThreshold; |
| | | |
| | | /** 超额止盈开关 */ |
| | | private Boolean placeExcessTakeProfit; |
| | | /** 止盈挂单模式:off=关闭 / concentrated=集中止盈 / dispersed=分散止盈 */ |
| | | private String placeExcessTakeProfit; |
| | | |
| | | /** 价格驱动开关 */ |
| | | private Boolean priceDriveEnabled; |
| | |
| | | if (params.containsKey("addPositionQuantity")) status.setAddPositionQuantity(intVal(params.get("addPositionQuantity"))); |
| | | if (params.containsKey("maxPositionPerSide")) status.setMaxPositionPerSide(intVal(params.get("maxPositionPerSide"))); |
| | | if (params.containsKey("addPositionStartThreshold")) status.setAddPositionStartThreshold(intVal(params.get("addPositionStartThreshold"))); |
| | | if (params.containsKey("placeExcessTakeProfit")) status.setPlaceExcessTakeProfit(boolVal(params.get("placeExcessTakeProfit"))); |
| | | if (params.containsKey("placeExcessTakeProfit")) status.setPlaceExcessTakeProfit(str(params.get("placeExcessTakeProfit"))); |
| | | if (params.containsKey("priceDriveEnabled")) status.setPriceDriveEnabled(boolVal(params.get("priceDriveEnabled"))); |
| | | if (params.containsKey("dualStopLossEnabled")) status.setDualStopLossEnabled(boolVal(params.get("dualStopLossEnabled"))); |
| | | if (params.containsKey("longStopLossPrice")) status.setLongStopLossPrice(str(params.get("longStopLossPrice"))); |
| | |
| | | `add_position_quantity` INT(11) DEFAULT 0 COMMENT '加仓数量', |
| | | `max_position_per_side` INT(11) DEFAULT 0 COMMENT '单边最大仓位', |
| | | `add_position_start_threshold` INT(11) DEFAULT 0 COMMENT '加仓启动阈值', |
| | | `place_excess_take_profit` TINYINT(1) DEFAULT 0 COMMENT '超额止盈开关', |
| | | `place_excess_take_profit` VARCHAR(16) DEFAULT 'off' COMMENT '止盈挂单模式:off / concentrated / dispersed', |
| | | `price_drive_enabled` TINYINT(1) DEFAULT 1 COMMENT '价格驱动开关', |
| | | `dual_stop_loss_enabled` TINYINT(1) DEFAULT 0 COMMENT '双开止损触发开关', |
| | | `long_stop_loss_price` VARCHAR(32) DEFAULT NULL COMMENT '多头止损触发价', |
| | |
| | | ADD COLUMN `dual_stop_loss_enabled` TINYINT(1) DEFAULT 0 COMMENT '双开止损触发开关' AFTER `price_drive_enabled`, |
| | | ADD COLUMN `long_stop_loss_price` VARCHAR(32) DEFAULT NULL COMMENT '多头止损触发价' AFTER `dual_stop_loss_enabled`, |
| | | ADD COLUMN `short_stop_loss_price` VARCHAR(32) DEFAULT NULL COMMENT '空头止损触发价' AFTER `long_stop_loss_price`; |
| | | |
| | | -- ============================================================ |
| | | -- 升级脚本:止盈挂单模式从布尔开关升级为三态字符串(2026-09 新增) |
| | | -- off=关闭 / concentrated=集中止盈 / dispersed=分散止盈 |
| | | -- ============================================================ |
| | | ALTER TABLE `strategy_status` |
| | | MODIFY COLUMN `place_excess_take_profit` VARCHAR(16) DEFAULT 'off' COMMENT '止盈挂单模式:off / concentrated / dispersed'; |
| | | -- 旧数据迁移:1(开启)→concentrated,0(关闭)→off |
| | | UPDATE `strategy_status` SET `place_excess_take_profit` = 'concentrated' WHERE `place_excess_take_profit` = '1'; |
| | | UPDATE `strategy_status` SET `place_excess_take_profit` = 'off' WHERE `place_excess_take_profit` = '0'; |
| | |
| | | addPositionQuantity: 1, |
| | | maxPositionPerSide: 0, |
| | | addPositionStartThreshold: 1, |
| | | placeExcessTakeProfit: false, |
| | | placeExcessTakeProfit: 'off', |
| | | priceDriveEnabled: true, |
| | | dualStopLossEnabled: false, |
| | | longStopLossPrice: '', |
| | |
| | | { key: 'addPositionStartThreshold', label: '加仓启动阈值 (次)', type: 'number', placeholder: '1', jtype: 'int', group: 'addon', tip: '前 N 次止损不触发加仓' }, |
| | | |
| | | { key: 'rounds', label: '运行轮数 (0=不限)', type: 'number', placeholder: '0', jtype: 'int', group: 'run', tip: '盈利重启达此轮数后停止' }, |
| | | { key: 'placeExcessTakeProfit', label: '超额止盈', type: 'select', options: [{ v: 'false', l: '关闭' }, { v: 'true', l: '开启' }], group: 'run' }, |
| | | { key: 'placeExcessTakeProfit', label: '止盈模式', type: 'select', options: [{ v: 'off', l: '关闭' }, { v: 'concentrated', l: '集中止盈' }, { v: 'dispersed', l: '分散止盈' }], group: 'run', tip: '超出基础仓位的加仓部分如何挂止盈' }, |
| | | { key: 'priceDriveEnabled', label: '价格驱动', type: 'select', options: [{ v: 'true', l: '开启' }, { v: 'false', l: '关闭' }], group: 'run' }, |
| | | |
| | | { key: 'dualStopLossEnabled', label: '双开止损触发', type: 'select', options: [{ v: 'false', l: '关闭' }, { v: 'true', l: '开启' }], group: 'dual-sl', tip: '开启后按下方多空止损触发价初始化双向止损单,任一触发后重挂另一侧止损' }, |