Administrator
2026-06-15 44e5dbee83a22eaf5d94ca390ea373361623cb96
refactor(gateApi): 修改网格交易止损扩展方法参数

- 为extendLongStopLoss方法添加gridId参数
- 为extendShortStopLoss方法添加gridId参数
- 将默认止损ID设置为当前gridId而不是固定值
- 更新多单成交时的止损扩展调用
- 更新空单成交时的止损扩展调用
1 files modified
12 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 12 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -608,7 +608,7 @@
            if (shortGridElement.isHasShortOrder() && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0") ){
                int filledQty = Integer.parseInt(shortGridElement.getShortTraderParam().getQuantity());
                shortEntryTraderIdParam(shortGridElement, null, false);
                extendShortStopLoss(filledQty);
                extendShortStopLoss(filledQty,shortGridElement.getId());
                log.info("[Gate] 空单成交 gridId:{}", filledQty);
                // 空仓持仓超过baseQuantity时,从gridId-2开始向外追挂止盈
@@ -646,7 +646,7 @@
                int filledQty = Integer.parseInt(longGridElement.getLongTraderParam().getQuantity());
                longEntryTraderIdParam(longGridElement, null, false);
                extendLongStopLoss(filledQty);
                extendLongStopLoss(filledQty,longGridElement.getId());
                log.info("[Gate] 多单成交 gridId:{}", filledQty);
                // 多仓持仓超过baseQuantity时,从gridId+2开始向外追挂止盈
@@ -1213,7 +1213,7 @@
        }
    }
    private void extendLongStopLoss(int filledQty) {
    private void extendLongStopLoss(int filledQty,int gridId) {
        int furthestSlId = 0;
        for (GridElement e : config.getGridElements()) {
            if (e.getLongStopLossOrderId() != null && e.getId() < furthestSlId) {
@@ -1221,7 +1221,7 @@
            }
        }
        if (furthestSlId == 0) {
            furthestSlId = -11;
            furthestSlId = gridId;
        }
        log.info("[Gate] 多仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty);
        for (int i = 0; i < filledQty; i++) {
@@ -1246,7 +1246,7 @@
        }
    }
    private void extendShortStopLoss(int filledQty) {
    private void extendShortStopLoss(int filledQty, int gridId) {
        int furthestSlId = 0;
        for (GridElement e : config.getGridElements()) {
            if (e.getShortStopLossOrderId() != null && e.getId() > furthestSlId) {
@@ -1254,7 +1254,7 @@
            }
        }
        if (furthestSlId == 0) {
            furthestSlId = 11;
            furthestSlId = gridId;
        }
        log.info("[Gate] 空仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty);
        for (int i = 0; i < filledQty; i++) {