From 83a4c9a1995a36df85c0d7bd6ffc36ed72e27172 Mon Sep 17 00:00:00 2001 From: dongzp_book <90fanhua@gmail.com> Date: Tue, 7 Jul 2026 13:52:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=82=E5=8D=95=E6=96=B9=E5=BC=8F=E5=8F=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trend/strategy/AutoGridStrategy.java | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/sample/trend/strategy/AutoGridStrategy.java b/src/main/java/com/sample/trend/strategy/AutoGridStrategy.java index c7e7961..4a2c827 100644 --- a/src/main/java/com/sample/trend/strategy/AutoGridStrategy.java +++ b/src/main/java/com/sample/trend/strategy/AutoGridStrategy.java @@ -420,29 +420,14 @@ public class AutoGridStrategy extends BaseStrategy { // ======================== 网格挂单 ======================== + /** + * 初始化仅挂下方一格买单,与运行中补单逻辑一致,避免网格间距调整后批量挂单失配。 + */ private void placeInitialBuyGrids() { if (currentPrice == null || currentGridGap == null) { fetchCurrentPriceFromRest(); } - if (currentPrice == null || currentGridGap == null) { - return; - } - - synchronized (tradeLock) { - int remainingSlots = gridCount - pendingBuyOrders.size(); - if (remainingSlots <= 0) { - return; - } - BigDecimal price = alignPriceDown(currentPrice, currentGridGap); - int placed = 0; - while (price.compareTo(lowerBound) >= 0 && placed < remainingSlots) { - if (!hasBuyOrderAt(price)) { - placeLimitBuyOrder(price); - placed++; - } - price = price.subtract(currentGridGap); - } - } + replenishBuyGrids(); } private void replenishBuyGrids() {