Administrator
2026-06-17 4cdead14455660727e45a9a99d519fb4b1db48e3
fix(gateApi): 修复网格交易追加止损单ID计算逻辑

- 在多仓追挂止损逻辑中引入interval变量控制ID间隔
- 在空仓追挂止损逻辑中引入interval变量控制ID间隔
- 当furthestSlId为0时将interval设置为2以确保正确的起始位置
- 使用interval变量替代硬编码的数值2来计算新的止损单ID
- 修复了止损单ID计算可能导致重复或跳过的bug
1 files modified
10 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -1229,12 +1229,15 @@
                furthestSlId = e.getId();
            }
        }
        int interval  = 1;
        if (furthestSlId == 0) {
            furthestSlId = gridId;
            interval = 2;
        }
        log.info("[Gate] 多仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty);
        for (int i = 0; i < filledQty; i++) {
            int newSlId = furthestSlId - i - 2;
            int newSlId = furthestSlId - i - interval;
            GridElement elem = GridElement.findById(newSlId);
            if (elem == null) {
                continue;
@@ -1262,12 +1265,15 @@
                furthestSlId = e.getId();
            }
        }
        int interval  = 1;
        if (furthestSlId == 0) {
            furthestSlId = gridId;
            interval = 2;
        }
        log.info("[Gate] 空仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty);
        for (int i = 0; i < filledQty; i++) {
            int newSlId = furthestSlId + i + 2;
            int newSlId = furthestSlId + i + interval;
            GridElement elem = GridElement.findById(newSlId);
            if (elem == null) {
                continue;