Administrator
5 days ago a10ffc2318f2b69fe34eca82829493f86ed8400e
fix(okx): 修复基底交易订单状态标记逻辑

- 在基底多头和空头订单开启时正确设置 opened 标志位
- 移除重复的状态标记以避免逻辑冲突
- 更新自动订单回调注释中的处理器名称
1 files modified
11 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java 11 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
@@ -288,12 +288,14 @@
                        .entryOrderId(orderId)
                        .build();
                config.setBaseLongTraderParam(baseLongTp);
                baseLongOpened = true;
            }, null);
            executor.openShort(size, (orderId) -> {
                TraderParam baseShortTp = TraderParam.builder()
                        .entryOrderId(orderId)
                        .build();
                config.setBaseShortTraderParam(baseShortTp);
                baseShortOpened = true;
            }, null);
            return;
        }
@@ -329,20 +331,19 @@
        boolean isLong = (direction == TraderParam.Direction.LONG);
        if (state == StrategyState.OPENING) {
            if (isLong && hasPosition && !baseLongOpened) {
            // 基底成交通知仅记录价格/数量,flag 在 REST 回调中设置
            if (isLong && hasPosition) {
                longActive = true;
                longPositionSize = size;
                longEntryPrice = entryPrice;
                longBaseEntryPrice = entryPrice;
                baseLongOpened = true;
                log.info("[OKX] 基底多成交价: {}", longBaseEntryPrice);
                tryGenerateQueues();
            } else if (!isLong && hasPosition && !baseShortOpened) {
            } else if (!isLong && hasPosition) {
                shortActive = true;
                shortPositionSize = size.abs();
                shortEntryPrice = entryPrice;
                shortBaseEntryPrice = entryPrice;
                baseShortOpened = true;
                log.info("[OKX] 基底空成交价: {}", shortBaseEntryPrice);
                tryGenerateQueues();
            }
@@ -412,7 +413,7 @@
    // ---- 自动订单(条件单)状态变更回调 ----
    /**
     * 自动订单状态变更回调。由 OrderAlgoOkxChannelHandler 调用。
     * 自动订单状态变更回调。由 OrdersOkxChannelHandler 调用。
     */
    public void onAutoOrder(String orderId, String status, String reason, String orderType, String tradeId) {
        if (state == StrategyState.STOPPED) {