Administrator
6 days ago 43c020c1e863f0dbeff630040750a305775aa745
fix(gateApi): 修复网格交易跨度重启逻辑

- 添加止盈单数量检查,确保多空止盈全部清空后才继续执行
- 新增多仓止盈单数量获取方法
- 新增空仓止盈单数量获取方法
- 优化日志输出,显示当前止盈单状态信息
2 files modified
14 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -1338,6 +1338,14 @@
        if (span <= 0) {
            return;
        }
        // 检查是否还有剩余止盈单,只有多空止盈全部清空才继续
        if (GridElement.getLongTakeProfitCount() > 0 || GridElement.getShortTakeProfitCount() > 0) {
            log.info("[Gate] 尚有未触发止盈单, 暂不检查跨度重启 longTpCount:{}, shortTpCount:{}",
                    GridElement.getLongTakeProfitCount(), GridElement.getShortTakeProfitCount());
            return;
        }
        BigDecimal step = config.getStep();
        if (step == null || step.compareTo(BigDecimal.ZERO) == 0) {
            return;
src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java
@@ -169,6 +169,12 @@
        return SHORT_TP_ORDER_ID_INDEX.get(orderId);
    }
    /** @return 当前多仓止盈单数量 */
    public static int getLongTakeProfitCount() { return LONG_TP_ORDER_ID_INDEX.size(); }
    /** @return 当前空仓止盈单数量 */
    public static int getShortTakeProfitCount() { return SHORT_TP_ORDER_ID_INDEX.size(); }
    /**
     * 根据多仓止损订单 ID 快速查找网格元素(O(1))。
     */