Administrator
2026-09-10 5b67ff5440086ed1c1296ca5a9c8ab3fb49276ae
src/main/java/com/xcong/excoin/modules/gateApi/GateTradeExecutor.java
@@ -54,6 +54,11 @@
    private static final String SETTLE = "usdt";
    /** 止盈/止损条件单创建失败后的重试次数 */
    private static final int TRIGGER_ORDER_RETRY_MAX_ATTEMPTS = 3;
    /** 止盈/止损条件单创建失败后的重试间隔(毫秒) */
    private static final long TRIGGER_ORDER_RETRY_DELAY_MS = 500L;
    /** Gate U 本位合约 REST API */
    private final FuturesApi futuresApi;
    /** 合约名称(如 ETH_USDT) */
@@ -179,6 +184,7 @@
                                Consumer<String> onSuccess) {
        executor.execute(() -> {
            FuturesPriceTriggeredOrder order = buildTriggeredOrder(triggerPrice, rule, orderType, size);
            for (int attempt = 1; attempt <= TRIGGER_ORDER_RETRY_MAX_ATTEMPTS; attempt++) {
            try {
                TriggerOrderResponse response = futuresApi.createPriceTriggeredOrder(SETTLE, order);
                log.info("[TradeExec] 止盈单已创建, 触发价:{}, 类型:{}, size:{}, id:{},idstr:{}",
@@ -187,10 +193,24 @@
                if (onSuccess != null) {
                    onSuccess.accept(orderId);
                }
                    return;
            } catch (Exception e) {
                    if (attempt < TRIGGER_ORDER_RETRY_MAX_ATTEMPTS) {
                        log.warn("[TradeExec] 止盈单创建失败, 触发价:{}, size:{}, 第{}次尝试失败, {}ms后重试, err:{}",
                                triggerPrice, size, attempt, TRIGGER_ORDER_RETRY_DELAY_MS, e.getMessage());
                        try {
                            Thread.sleep(TRIGGER_ORDER_RETRY_DELAY_MS);
                        } catch (InterruptedException ie) {
                            Thread.currentThread().interrupt();
                            marketClose(size);
                            return;
                        }
                    } else {
                log.error("[TradeExec] 止盈单创建失败, 触发价:{}, size:{}, 立即市价止盈", triggerPrice, size, e);
                marketClose(size);
            }
                }
            }
        });
    }