| | |
| | | return; |
| | | } |
| | | |
| | | // 止损触发:先取消该方向全部遗留多开仓单(对向加仓/补仓/旧追单),再挂新追单, |
| | | // 避免旧单与新追单重复建仓(与价格驱动的扫荡口径一致) |
| | | cancelAllLongEntryOrders(); |
| | | |
| | | // 止损追单:同一网格可有多笔挂单,不判断 isHasLongOrder,直接挂单 |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | String size = calculateEntryQuantity(true, true, gridStopLossSize); |
| | |
| | | placeEntryOrderWithPreFlag(newEntryGrid, true, triggerPrice, |
| | | FuturesPriceTrigger.RuleEnum.NUMBER_1, size, |
| | | hasAdd ? pendingAddEntryOrderIds::add : null); |
| | | } |
| | | |
| | | // 取消 gridId+2 位置的所有多单 |
| | | int cancelGridId = gridId + 2; |
| | | GridElement cancelGrid = GridElement.findById(cancelGridId); |
| | | if (cancelGrid != null && cancelGrid.isHasLongOrder()) { |
| | | for (String cancelOrderId : new ArrayList<>(cancelGrid.getLongOrderIds())) { |
| | | executor.cancelConditionalOrder(cancelOrderId, oid -> { |
| | | longEntryTraderIdParam(cancelGrid, cancelOrderId, false); |
| | | log.info("[Gate] 多仓止损触发, 取消gridId:{}的多单,{}", cancelGridId, cancelOrderId); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 自定义止损模式:第一次止损触发时,取消未触发侧(空仓)自定义止损单并重挂默认阶梯 |
| | |
| | | return; |
| | | } |
| | | |
| | | // 止损触发:先取消该方向全部遗留空开仓单(对向加仓/补仓/旧追单),再挂新追单, |
| | | // 避免旧单与新追单重复建仓(与价格驱动的扫荡口径一致) |
| | | cancelAllShortEntryOrders(); |
| | | |
| | | // 止损追单:同一网格可有多笔挂单,不判断 isHasShortOrder,直接挂单 |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | String size = calculateEntryQuantity(false, true, gridStopLossSize); |
| | |
| | | placeEntryOrderWithPreFlag(newEntryGrid, false, triggerPrice, |
| | | FuturesPriceTrigger.RuleEnum.NUMBER_2, negate(size), |
| | | hasAdd ? pendingAddEntryOrderIds::add : null); |
| | | } |
| | | |
| | | // 取消 gridId-2 位置的所有空单 |
| | | int cancelGridId = gridId - 2; |
| | | GridElement cancelGrid = GridElement.findById(cancelGridId); |
| | | if (cancelGrid != null && cancelGrid.isHasShortOrder()) { |
| | | for (String cancelOrderId : new ArrayList<>(cancelGrid.getShortOrderIds())) { |
| | | executor.cancelConditionalOrder(cancelOrderId, oid -> { |
| | | shortEntryTraderIdParam(cancelGrid, cancelOrderId, false); |
| | | log.info("[Gate] 空仓止损触发, 取消gridId:{}的空单,{}", cancelGridId, cancelOrderId); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 自定义止损模式:第一次止损触发时,取消未触发侧(多仓)自定义止损单并重挂默认阶梯 |
| | |
| | | */ |
| | | private void cancelAllLongEntryOrders() { |
| | | for (GridElement e : config.getGridElements()) { |
| | | if (e.getId() == 0) { |
| | | continue; // 基底网格 0 是市价单成交,非条件开仓单 |
| | | } |
| | | for (String oid : new ArrayList<>(e.getLongOrderIds())) { |
| | | // 同步清理对向加仓/补仓/加仓标记登记表,避免残留失效记录 |
| | | tpOppositeLongOrderGridMap.remove(oid); |
| | | tpReplenishLongOrderMap.remove(oid); |
| | | pendingAddEntryOrderIds.remove(oid); |
| | | executor.cancelConditionalOrder(oid, o -> {}); |
| | | } |
| | | e.getLongTraderParam().setEntryOrderId(null); |
| | |
| | | */ |
| | | private void cancelAllShortEntryOrders() { |
| | | for (GridElement e : config.getGridElements()) { |
| | | if (e.getId() == 0) { |
| | | continue; // 基底网格 0 是市价单成交,非条件开仓单 |
| | | } |
| | | for (String oid : new ArrayList<>(e.getShortOrderIds())) { |
| | | // 同步清理对向加仓/补仓/加仓标记登记表,避免残留失效记录 |
| | | tpOppositeShortOrderGridMap.remove(oid); |
| | | tpReplenishShortOrderMap.remove(oid); |
| | | pendingAddEntryOrderIds.remove(oid); |
| | | executor.cancelConditionalOrder(oid, o -> {}); |
| | | } |
| | | e.getShortTraderParam().setEntryOrderId(null); |