Administrator
2026-06-10 aa50bfb6c8d0ed688dd603f31e9066a0a9969296
refactor(gateApi): 优化网格交易服务中的止损和仓位管理逻辑

- 移除长仓和短仓止损触发条件中的持仓数量判断
- 在仓位归零时增加对订单状态的检查以避免重复下单
- 重构网格元素查找逻辑以提高代码可读性
- 统一订单取消逻辑的处理流程
- 优化日志记录以提供更准确的执行状态信息
1 files modified
6 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -854,7 +854,6 @@
            if (BigDecimal.ZERO.compareTo( matched) == 0) {
                return;
            }
            log.info("[Gate] 多仓仓位归零 空仓队列触发, 匹配:{},当前价:{}", matched, currentPrice);
            GridElement matchedUpGridElement = GridElement.findByPrice(matched);
            if (matchedUpGridElement != null){
@@ -863,6 +862,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();
@@ -902,8 +902,6 @@
                return;
            }
            log.info("[Gate] 空仓仓位归零 多仓队列触发, 匹配:{},当前价:{}", matched, currentPrice);
            GridElement matchedUpGridElement = GridElement.findByPrice(matched);
            if (matchedUpGridElement != null){
                if(!matchedUpGridElement.isHasShortOrder()){
@@ -911,7 +909,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();