Administrator
2026-05-28 b7a2fa0ea40b15bd5b60d737cb96764884dcaaaa
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -428,40 +428,8 @@
                    tryGenerateQueues();
                }else {
                    longPositionSize = size;
                    List<GridElement> allShortOrders = GridElement.findAllLongOrders(longEntryPrice);
                    if (CollUtil.isNotEmpty(allShortOrders)){
                        GridElement keep = allShortOrders.stream()
                                .max((a, b) -> a.getGridPrice().compareTo(b.getGridPrice()))
                                .orElse(null);
                        for (GridElement e : allShortOrders) {
                            if (e == keep) {
                                continue;
                            }
                            executor.cancelConditionalOrder(
                                    e.getLongOrderId(),
                                    orderId -> {
                                        longEntryTraderIdParam(
                                                e,
                                                null,
                                                false
                                        );
                                    }
                            );
                            if (e.getLongTakeProfitOrderId() != null){
                                executor.cancelConditionalOrder(
                                        e.getLongTakeProfitOrderId(),
                                        orderId -> {
                                            longTakeProfitTraderIdParam(
                                                    e,
                                                    null,
                                                    false
                                            );
                                        }
                                );
                            }
                        }
                    }
                    checkShortEntryOrderToCancel();
                    checkLongEntryOrderToCancel();
                }
            } else {
                longActive = false;
@@ -479,6 +447,17 @@
                    tryGenerateQueues();
                }else {
                    shortPositionSize = size.abs();
                    checkShortEntryOrderToCancel();
                    checkLongEntryOrderToCancel();
                }
            } else {
                shortActive = false;
                shortPositionSize = BigDecimal.ZERO;
            }
        }
    }
    private void checkShortEntryOrderToCancel() {
                    List<GridElement> allLongOrders = GridElement.findAllShortOrders(shortEntryPrice);
                    if (CollUtil.isNotEmpty(allLongOrders)){
                        GridElement keep = allLongOrders.stream()
@@ -513,9 +492,40 @@
                        }
                    }
                }
            } else {
                shortActive = false;
                shortPositionSize = BigDecimal.ZERO;
    private void checkLongEntryOrderToCancel() {
        List<GridElement> allShortOrders = GridElement.findAllLongOrders(longEntryPrice);
        if (CollUtil.isNotEmpty(allShortOrders)){
            GridElement keep = allShortOrders.stream()
                    .max((a, b) -> a.getGridPrice().compareTo(b.getGridPrice()))
                    .orElse(null);
            for (GridElement e : allShortOrders) {
                if (e == keep) {
                    continue;
                }
                executor.cancelConditionalOrder(
                        e.getLongOrderId(),
                        orderId -> {
                            longEntryTraderIdParam(
                                    e,
                                    null,
                                    false
                            );
                        }
                );
                if (e.getLongTakeProfitOrderId() != null){
                    executor.cancelConditionalOrder(
                            e.getLongTakeProfitOrderId(),
                            orderId -> {
                                longTakeProfitTraderIdParam(
                                        e,
                                        null,
                                        false
                                );
                            }
                    );
                }
            }
        }
    }