feat(stations): 添加加仓停止阈值功能
- 在策略状态实体中新增加仓停止阈值字段
- 更新数据库表结构,添加加仓停止阈值列
- 在前端仪表板界面添加加仓停止阈值配置选项
- 实现加仓停止阈值参数的后端处理逻辑
- 完善相关注释说明加仓停止阈值的作用机制
| | |
| | | /** 加仓启动阈值 */ |
| | | private Integer addPositionStartThreshold; |
| | | |
| | | /** 加仓停止阈值:启动加仓后累计次数超过该值时,加仓张数恢复为基础张数;0=不限制 */ |
| | | private Integer addPositionStopThreshold; |
| | | |
| | | /** 止盈挂单模式:off=关闭 / concentrated=集中止盈 / dispersed=分散止盈 */ |
| | | private String placeExcessTakeProfit; |
| | | |
| | |
| | | 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("addPositionStopThreshold")) status.setAddPositionStopThreshold(intVal(params.get("addPositionStopThreshold"))); |
| | | 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"))); |
| | |
| | | `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 '加仓启动阈值', |
| | | `add_position_stop_threshold` INT(11) DEFAULT 0 COMMENT '加仓停止阈值(0=不限制)', |
| | | `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 '双开止损触发开关', |
| | |
| | | ALTER TABLE `strategy_status` |
| | | ADD COLUMN `base_take_profit_per_grid` VARCHAR(32) DEFAULT NULL COMMENT '单格止盈张数(基础仓位止盈,支持小数)' AFTER `tp_trigger_opposite_add_quantity`, |
| | | ADD COLUMN `base_take_profit_grid_count` INT(11) DEFAULT 0 COMMENT '止盈网格数量(基础仓位止盈)' AFTER `base_take_profit_per_grid`; |
| | | |
| | | -- ============================================================ |
| | | -- 升级脚本:加仓停止阈值(2026-10 新增) |
| | | -- 与加仓启动阈值配合:启动阈值控制从第几次止损开始加仓, |
| | | -- 停止阈值控制启动后的最大加仓次数,超过后加仓张数恢复为基础张数;0=不限制 |
| | | -- ============================================================ |
| | | ALTER TABLE `strategy_status` |
| | | ADD COLUMN `add_position_stop_threshold` INT(11) DEFAULT 0 COMMENT '加仓停止阈值(0=不限制)' AFTER `add_position_start_threshold`; |
| | |
| | | addPositionQuantity: 1, |
| | | maxPositionPerSide: 0, |
| | | addPositionStartThreshold: 1, |
| | | addPositionStopThreshold: 0, |
| | | placeExcessTakeProfit: 'off', |
| | | priceDriveEnabled: true, |
| | | dualStopLossEnabled: false, |
| | |
| | | { key: 'addPositionQuantity', label: '加仓数量 (张)', type: 'number', placeholder: '1', jtype: 'int', group: 'addon' }, |
| | | { key: 'maxPositionPerSide', label: '单边最大仓位 (0=不限)', type: 'number', placeholder: '0', jtype: 'int', group: 'addon' }, |
| | | { key: 'addPositionStartThreshold', label: '加仓启动阈值 (次)', type: 'number', placeholder: '1', jtype: 'int', group: 'addon', tip: '前 N 次止损不触发加仓' }, |
| | | { 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: '止盈成交后在对向挂出的加仓张数' }, |
| | | |