Administrator
2026-06-10 5a9a6dedff749b410c62837f2a5c8900328cdb37
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -480,6 +480,8 @@
                e.printStackTrace();
            }
            closeExistingPositions();
            state = StrategyState.STOPPED;
            // 提交到 executor 末尾:单线程FIFO保证前面所有平仓/取消任务完成后才重置
            executor.submitTask(() -> {
                try { Thread.sleep(3000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
@@ -854,7 +856,6 @@
            if (BigDecimal.ZERO.compareTo( matched) == 0) {
                return;
            }
            log.info("[Gate] 多仓仓位归零 空仓队列触发, 匹配:{},当前价:{}", matched, currentPrice);
            GridElement matchedUpGridElement = GridElement.findByPrice(matched);
            if (matchedUpGridElement != null){
@@ -863,6 +864,7 @@
                    GridElement newEntryGrid = GridElement.findById(upId);
                    if (newEntryGrid != null) {
                        log.info("[Gate] 多仓仓位归零 空仓队列触发, 匹配:{},当前价:{}", matched, currentPrice);
                        if (!newEntryGrid.isHasLongOrder()) {
                            BigDecimal triggerPrice = newEntryGrid.getGridPrice();
                            String size = config.getBaseQuantity();
@@ -876,9 +878,10 @@
                        GridElement cancelGridElement = GridElement.findById(newEntryGrid.getUpId());
                        if (cancelGridElement != null && cancelGridElement.isHasLongOrder()) {
                            String longOrderId = cancelGridElement.getLongOrderId();
                            longEntryTraderIdParam(cancelGridElement, null, false);
                            executor.cancelConditionalOrder(cancelGridElement.getLongOrderId(), oid -> {
                                log.info("[Gate] 多仓仓位归零, 取消gridId:{}的多单", cancelGridElement.getId());
                            executor.cancelConditionalOrder(longOrderId, oid -> {
                                log.info("[Gate] 多仓仓位归零, 取消gridId:{}的多单,{}", cancelGridElement.getId(),longOrderId);
                            });
                        }
                    }
@@ -902,8 +905,6 @@
                return;
            }
            log.info("[Gate] 空仓仓位归零 多仓队列触发, 匹配:{},当前价:{}", matched, currentPrice);
            GridElement matchedUpGridElement = GridElement.findByPrice(matched);
            if (matchedUpGridElement != null){
                if(!matchedUpGridElement.isHasShortOrder()){
@@ -911,7 +912,7 @@
                    GridElement newEntryGrid = GridElement.findById(downId);
                    if (newEntryGrid != null) {
                        log.info("[Gate] 空仓仓位归零 多仓队列触发, 匹配:{},当前价:{}", matched, currentPrice);
                        if (!newEntryGrid.isHasShortOrder()){
                            BigDecimal triggerPrice = newEntryGrid.getGridPrice();
                            String size = config.getBaseQuantity();
@@ -927,9 +928,10 @@
                         * 看是否有空仓挂单,有就取消
                         */
                        if (cancelGridElement != null && cancelGridElement.isHasShortOrder()) {
                            String shortOrderId = cancelGridElement.getShortOrderId();
                            shortEntryTraderIdParam(cancelGridElement, null, false);
                            executor.cancelConditionalOrder(cancelGridElement.getShortOrderId(), oid -> {
                                log.info("[Gate] 空仓仓位归零, 取消gridId:{}的多单", cancelGridElement.getId());
                            executor.cancelConditionalOrder(shortOrderId, oid -> {
                                log.info("[Gate] 空仓仓位归零, 取消gridId:{}的多单{}", cancelGridElement.getId(),shortOrderId);
                            });
                        }