Administrator
7 days ago e4c5d36a2da3fabd0f233df15a563d520d08b287
src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
@@ -298,6 +298,12 @@
            return;
        }
        // OPENING 状态下若 WS 仓位已确认但 REST 回调尚未完成,等标记价格推送时重试队列生成
        if (state == StrategyState.OPENING &&
                baseLongOpened && baseShortOpened) {
            tryGenerateQueues();
        }
        if (state == StrategyState.ACTIVE &&
                !longActive &&
                longPositionSize.compareTo(BigDecimal.ZERO) == 0) {
@@ -590,6 +596,12 @@
    private void tryGenerateQueues() {
        if (baseLongOpened && baseShortOpened) {
            // 确保 openLong/openShort 的 REST 回调已完成(WS 推送可能比回调更快到达)
            if (config.getBaseLongTraderParam() == null || config.getBaseShortTraderParam() == null) {
                log.warn("[OKX] 基底REST回调尚未完成, 延后队列生成");
                return;
            }
            generateShortQueue();
            generateLongQueue();
            updateGridElements();
@@ -629,7 +641,7 @@
                }
                BigDecimal triggerPrice = elem.getGridPrice();
                int finalId = id;
                executor.placeTakeProfit(triggerPrice, "close_short", config.getQuantity(),
                executor.placeStopLoss(triggerPrice, "close_short", config.getQuantity(),
                        profitId -> {
                            elem.setShortStopLossOrderId(profitId);
                            GridElement.refreshIndices();
@@ -643,7 +655,7 @@
                }
                BigDecimal triggerPrice = elem.getGridPrice();
                int finalId = id;
                executor.placeTakeProfit(triggerPrice, "close_long", config.getQuantity(),
                executor.placeStopLoss(triggerPrice, "close_long", config.getQuantity(),
                        profitId -> {
                            elem.setLongStopLossOrderId(profitId);
                            GridElement.refreshIndices();
@@ -1132,7 +1144,7 @@
            }
            BigDecimal triggerPrice = elem.getGridPrice();
            int finalSlId = newSlId;
            executor.placeTakeProfit(triggerPrice, "close_long", config.getQuantity(),
            executor.placeStopLoss(triggerPrice, "close_long", config.getQuantity(),
                    profitId -> {
                        elem.setLongStopLossOrderId(profitId);
                        GridElement.refreshIndices();
@@ -1160,7 +1172,7 @@
            }
            BigDecimal triggerPrice = elem.getGridPrice();
            int finalSlId = newSlId;
            executor.placeTakeProfit(triggerPrice, "close_short", config.getQuantity(),
            executor.placeStopLoss(triggerPrice, "close_short", config.getQuantity(),
                    profitId -> {
                        elem.setShortStopLossOrderId(profitId);
                        GridElement.refreshIndices();