Administrator
2026-09-21 365110e09cb7559b4c6bc2e81af8720b95f69319
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -150,7 +150,7 @@
    /** 最近触发止损的空头网格ID */
    private volatile int lastShortStopLossGridId = Integer.MAX_VALUE;
    /** 自定义止损模式激活标记:true=尚未发生第一次止损触发,第一次触发后置 false(触发未触发侧重挂默认) */
    private final AtomicBoolean customStopLossModeActive = new AtomicBoolean(false);
    private final AtomicBoolean dualStopLossModeActive = new AtomicBoolean(false);
    private volatile BigDecimal lastKlinePrice;
    private volatile BigDecimal markPrice = BigDecimal.ZERO;
@@ -365,7 +365,7 @@
        accumulatedShortLossCount = 0;
        lastLongStopLossGridId = Integer.MAX_VALUE;
        lastShortStopLossGridId = Integer.MAX_VALUE;
        customStopLossModeActive.set(false);
        dualStopLossModeActive.set(false);
        shortPriceQueue.clear();
        longPriceQueue.clear();
        totalShortPriceQueue.clear();
@@ -978,7 +978,7 @@
//                );
//            }
            if (config.isCustomStopLossEnabled()) {
            if (config.isDualStopLossEnabled()) {
                placeCustomStopLosses();
            } else {
                placeDefaultStopLossLadders();
@@ -995,10 +995,10 @@
     * 多仓止损:NUMBER_2(价格 ≤ 触发价平多),空仓止损:NUMBER_1(价格 ≥ 触发价平空)。
     */
    private void placeCustomStopLosses() {
        customStopLossModeActive.set(true);
        dualStopLossModeActive.set(true);
        String baseQty = config.getBaseQuantity();
        BigDecimal longPrice = config.getLongCustomStopLossPrice();
        BigDecimal shortPrice = config.getShortCustomStopLossPrice();
        BigDecimal longPrice = config.getLongStopLossPrice();
        BigDecimal shortPrice = config.getShortStopLossPrice();
        if (longPrice != null && longPrice.compareTo(BigDecimal.ZERO) > 0) {
            GridElement longElem = findNearestGridElementByPrice(longPrice);
@@ -1654,7 +1654,7 @@
        }
        // 自定义止损模式:第一次止损触发时,取消未触发侧(空仓)自定义止损单并重挂默认阶梯
        if (config.isCustomStopLossEnabled() && customStopLossModeActive.compareAndSet(true, false)) {
        if (config.isDualStopLossEnabled() && dualStopLossModeActive.compareAndSet(true, false)) {
            cancelAllShortStopLossesOnly();
            placeDefaultShortStopLossLadder();
            log.info("[Gate] 自定义止损首次触发(多仓), 已取消空仓自定义止损并重挂默认阶梯");
@@ -1713,7 +1713,7 @@
        }
        // 自定义止损模式:第一次止损触发时,取消未触发侧(多仓)自定义止损单并重挂默认阶梯
        if (config.isCustomStopLossEnabled() && customStopLossModeActive.compareAndSet(true, false)) {
        if (config.isDualStopLossEnabled() && dualStopLossModeActive.compareAndSet(true, false)) {
            cancelAllLongStopLossesOnly();
            placeDefaultLongStopLossLadder();
            log.info("[Gate] 自定义止损首次触发(空仓), 已取消多仓自定义止损并重挂默认阶梯");
@@ -1943,7 +1943,8 @@
            return;
        }
        int totalOrders = filledQty / qty;
        // [Gate] 止损只针对初始开仓仓位(baseQuantity),加仓部分只做止盈
        int totalOrders = baseQty / qty;
        int[] orders = new int[gridCount];
        if (gridCount == 1) {
@@ -2005,7 +2006,8 @@
            return;
        }
        int totalOrders = filledQty / qty;
        // [Gate] 止损只针对初始开仓仓位(baseQuantity),加仓部分只做止盈
        int totalOrders = baseQty / qty;
        int[] orders = new int[gridCount];
        if (gridCount == 1) {