Administrator
3 days ago c5f7e8303480a2b49c415d6d2e9c96bc4e159e52
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -122,6 +122,12 @@
            this.initialPrincipal = new BigDecimal(account.getTotal());
            log.info("[Gate] 初始本金: {} USDT", initialPrincipal);
            //设置持仓模式为双向持仓
            Boolean inDualMode = account.getInDualMode();
            if (!inDualMode) {
                futuresApi.setDualModeCall(SETTLE,true,null);
            }
            if (!config.getPositionMode().equals(account.getPositionMode())) {
                futuresApi.setPositionMode(SETTLE, config.getPositionMode());
            }
@@ -356,10 +362,11 @@
                }
            }
        }
        log.info("[Gate] 空队列:{}", shortPriceQueue);
        if (matched.isEmpty()) {
            log.info("[Gate] 空仓队列未触发, 当前价:{}", currentPrice);
            return;
        }
        log.info("[Gate] 空仓队列触发, 匹配{}个元素, 当前价:{}", matched.size(), currentPrice);
        if (!isMarginSafe()) {
            log.warn("[Gate] 保证金超限,跳过空单开仓");
@@ -375,7 +382,9 @@
                min = min.multiply(BigDecimal.ONE.subtract(step)).setScale(1, RoundingMode.HALF_UP);
                shortPriceQueue.add(min);
            }
            shortPriceQueue.sort((a, b) -> b.compareTo(a));
            shortPriceQueue.sort(BigDecimal::compareTo);
            log.info("[Gate] 空队列:{}", shortPriceQueue);
        }
        synchronized (longPriceQueue) {
@@ -384,6 +393,8 @@
            while (longPriceQueue.size() > config.getGridQueueSize()) {
                longPriceQueue.remove(longPriceQueue.size() - 1);
            }
            log.info("[Gate] 多队列:{}", shortPriceQueue);
        }
    }
@@ -398,7 +409,9 @@
                }
            }
        }
        log.info("[Gate] 多队列:{}", shortPriceQueue);
        if (matched.isEmpty()) {
            log.info("[Gate] 多仓队列未触发,  当前价:{}", currentPrice);
            return;
        }
@@ -418,6 +431,8 @@
                longPriceQueue.add(max);
            }
            longPriceQueue.sort(BigDecimal::compareTo);
            log.info("[Gate] 多队列:{}", shortPriceQueue);
        }
        synchronized (shortPriceQueue) {
@@ -426,6 +441,8 @@
            while (shortPriceQueue.size() > config.getGridQueueSize()) {
                shortPriceQueue.remove(shortPriceQueue.size() - 1);
            }
            log.info("[Gate] 空队列:{}", shortPriceQueue);
        }
    }