| | |
| | | if (newEntryGrid != null) { |
| | | |
| | | String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue()) + Integer.parseInt(config.getQuantity())); |
| | | |
| | | // 向下检查是否已有多单挂在更低价格网格,有则跳过(防止价格回升后重复挂单) |
| | | boolean hasLongOrderBelow = false; |
| | | GridElement checkDownCursor = GridElement.findById(newEntryGrid.getDownId()); |
| | | while (checkDownCursor != null) { |
| | | if (checkDownCursor.isHasLongOrder()) { |
| | | hasLongOrderBelow = true; |
| | | log.info("[Gate] 多仓仓位归零 gridId:{}, 下方gridId:{}已有多单, 跳过本次挂单", |
| | | newEntryGrid.getId(), checkDownCursor.getId()); |
| | | break; |
| | | } |
| | | Integer nextDownId = checkDownCursor.getDownId(); |
| | | checkDownCursor = nextDownId != null ? GridElement.findById(nextDownId) : null; |
| | | } |
| | | |
| | | // 向上遍历取消所有遗留多单(跳过基础入场网格0) |
| | | GridElement cancelCursor = GridElement.findById(newEntryGrid.getUpId()); |
| | | while (cancelCursor != null) { |
| | |
| | | cancelCursor = nextUpId != null ? GridElement.findById(nextUpId) : null; |
| | | } |
| | | // log.info("[Gate-2] 多仓仓位归零 空仓队列触发, 匹配:{},当前价:{}", matched, currentPrice); |
| | | if (!newEntryGrid.isHasLongOrder()) { |
| | | if (!newEntryGrid.isHasLongOrder() && !hasLongOrderBelow) { |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | String size = quantity; |
| | | log.info("[Gate] 多仓仓位归零 gridId:{}, 挂{}基础张多单", |
| | |
| | | |
| | | // String quantity = String.valueOf((accumulatedShortLossCount + 1) * Integer.parseInt(config.getQuantity())); |
| | | String quantity = String.valueOf(Math.max(queryPositionSize(Position.ModeEnum.DUAL_LONG), longPositionSize.intValue()) + Integer.parseInt(config.getQuantity())); |
| | | |
| | | // 向上检查是否已有空单挂在更高价格网格,有则跳过(防止价格回落后重复挂单) |
| | | boolean hasShortOrderAbove = false; |
| | | GridElement checkUpCursor = GridElement.findById(newEntryGrid.getUpId()); |
| | | while (checkUpCursor != null) { |
| | | if (checkUpCursor.isHasShortOrder()) { |
| | | hasShortOrderAbove = true; |
| | | log.info("[Gate] 空仓仓位归零 gridId:{}, 上方gridId:{}已有空单, 跳过本次挂单", |
| | | newEntryGrid.getId(), checkUpCursor.getId()); |
| | | break; |
| | | } |
| | | Integer nextUpId = checkUpCursor.getUpId(); |
| | | checkUpCursor = nextUpId != null ? GridElement.findById(nextUpId) : null; |
| | | } |
| | | |
| | | // 向下遍历取消所有遗留空单(跳过基础入场网格0) |
| | | GridElement cancelCursor = GridElement.findById(newEntryGrid.getDownId()); |
| | | while (cancelCursor != null) { |
| | |
| | | cancelCursor = nextDownId != null ? GridElement.findById(nextDownId) : null; |
| | | } |
| | | // log.info("[Gate-4] 空仓仓位归零 多仓队列触发, 匹配:{},当前价:{}", matched, currentPrice); |
| | | if (!newEntryGrid.isHasShortOrder()){ |
| | | if (!newEntryGrid.isHasShortOrder() && !hasShortOrderAbove){ |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | String size = quantity; |
| | | log.info("[Gate] 空仓仓位归零 gridId:{}, 挂{}基础张多单", |