refactor(station): 重构基础仓位止盈参数为总数量配置
- 移除单格止盈张数和止盈网格数量字段
- 新增原始仓位止盈总数量字段以替代旧逻辑
- 更新前端仪表盘表单配置及提示信息
- 修改数据库表结构及升级脚本以支持新字段
- 更新后端实体类及服务层的参数解析逻辑
| | |
| | | /** 仓位止盈补仓开关:true=止盈触发时在对侧止损位挂同方向同张数开仓单,false=保持现有逻辑 */ |
| | | private Boolean tpPositionReplenishEnabled; |
| | | |
| | | /** 单格止盈张数(基础仓位止盈:每个网格挂的止盈张数,支持小数) */ |
| | | private String baseTakeProfitPerGrid; |
| | | |
| | | /** 止盈网格数量(基础仓位止盈:挂止盈的网格数量) */ |
| | | private Integer baseTakeProfitGridCount; |
| | | /** 原始仓位止盈总数量(平均分配到对手盘止损位前的所有网格,余数挂最后一格,每格至少1张) */ |
| | | private Integer baseTakeProfitTotalQty; |
| | | |
| | | /** 当前轮次 */ |
| | | private Integer currentRound; |
| | |
| | | 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("baseTakeProfitTotalQty")) status.setBaseTakeProfitTotalQty(intVal(params.get("baseTakeProfitTotalQty"))); |
| | | if (params.containsKey("rounds")) status.setTotalRounds(intVal(params.get("rounds"))); |
| | | if (params.containsKey("principal")) status.setPrincipal(str(params.get("principal"))); |
| | | } |
| | |
| | | `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 '止盈网格数量(基础仓位止盈)', |
| | | `base_take_profit_total_qty` INT(11) DEFAULT 0 COMMENT '原始仓位止盈总数量(平均分配到对手盘止损位前的所有网格,余数挂最后一格)', |
| | | `current_round` INT(11) DEFAULT 0 COMMENT '当前轮次', |
| | | `total_rounds` INT(11) DEFAULT 0 COMMENT '总轮数上限', |
| | | `accumulated_long_loss` INT(11) DEFAULT 0 COMMENT '多头累计止损次数', |
| | |
| | | ADD COLUMN `tp_trigger_opposite_add_quantity` INT(11) DEFAULT 0 COMMENT '对向加仓挂单数量' AFTER `tp_trigger_opposite_add_enabled`; |
| | | |
| | | -- ============================================================ |
| | | -- 升级脚本:基础仓位止盈挂单参数(2026-09 新增) |
| | | -- 升级脚本:原始仓位止盈挂单优化(2026-11 变更) |
| | | -- 原 base_take_profit_per_grid / base_take_profit_grid_count 弃用(旧列保留不删,新代码不再读取) |
| | | -- ============================================================ |
| | | 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`; |
| | | ADD COLUMN `base_take_profit_total_qty` INT(11) DEFAULT 0 COMMENT '原始仓位止盈总数量(平均分配到对手盘止损位前的所有网格,余数挂最后一格)' AFTER `tp_position_replenish_enabled`; |
| | | |
| | | -- ============================================================ |
| | | -- 升级脚本:仓位止盈补仓开关(2026-10 新增) |
| | |
| | | tpTriggerOppositeAddEnabled: false, |
| | | tpTriggerOppositeAddQuantity: 0, |
| | | tpPositionReplenishEnabled: false, |
| | | baseTakeProfitPerGrid: 0, |
| | | baseTakeProfitGridCount: 0, |
| | | baseTakeProfitTotalQty: 0, |
| | | }; |
| | | |
| | | async function loadConfig(md5) { |
| | |
| | | { key: 'quantity', label: '每次下单张数', type: 'number', placeholder: '2', jtype: 'string', group: 'grid' }, |
| | | { key: 'maxPositionSize', label: '最大持仓张数', type: 'number', placeholder: '4', jtype: 'int', group: 'grid' }, |
| | | { key: 'takeProfitGridSpan', label: '止盈网格跨度', type: 'number', placeholder: '2', jtype: 'int', group: 'grid' }, |
| | | { key: 'baseTakeProfitPerGrid', label: '单格止盈张数', type: 'number', step: 'any', placeholder: '0', jtype: 'decimal', group: 'grid', tip: '基础仓位止盈:每个网格挂的止盈张数(支持小数)' }, |
| | | { key: 'baseTakeProfitGridCount', label: '止盈网格数量', type: 'number', placeholder: '0', jtype: 'int', group: 'grid', tip: '基础仓位止盈:挂止盈的网格数量' }, |
| | | { key: 'baseTakeProfitTotalQty', label: '原始仓位止盈总数量', type: 'number', placeholder: '0', jtype: 'int', group: 'grid', tip: '止盈总量平均分配到对手盘止损位前的所有网格,余数挂最后一格,每格至少1张' }, |
| | | |
| | | { key: 'expectedProfit', label: '预期收益 (USDT)', type: 'number', step: '0.01', placeholder: '0.15', jtype: 'decimal', group: 'risk' }, |
| | | { key: 'maxLoss', label: '最大亏损 (USDT)', type: 'number', step: '0.01', placeholder: '1.5', jtype: 'decimal', group: 'risk' }, |