| | |
| | | private Integer upId; |
| | | /** 下一个网格编号,null 表示无下一级 */ |
| | | private Integer downId; |
| | | /** 多仓挂单订单 ID */ |
| | | private String longOrderId; |
| | | /** 空仓挂单订单 ID */ |
| | | private String shortOrderId; |
| | | /** 多仓挂单订单 ID 列表(支持同一网格多个挂单,由止损追单产生) */ |
| | | private List<String> longOrderIds = new ArrayList<>(); |
| | | /** 空仓挂单订单 ID 列表(支持同一网格多个挂单,由止损追单产生) */ |
| | | private List<String> shortOrderIds = new ArrayList<>(); |
| | | /** 多仓止盈订单 ID */ |
| | | private String longTakeProfitOrderId; |
| | | /** 空仓止盈订单 ID */ |
| | |
| | | e.getUpId(), |
| | | e.getDownId(), |
| | | e.isHasLongOrder() ? "有" : "无", |
| | | e.getLongOrderId() != null ? e.getLongOrderId() : "-", |
| | | e.hasLongOrderIds() ? String.join(",", e.getLongOrderIds()) : "-", |
| | | e.isHasShortOrder() ? "有" : "无", |
| | | e.getShortOrderId() != null ? e.getShortOrderId() : "-", |
| | | e.hasShortOrderIds() ? String.join(",", e.getShortOrderIds()) : "-", |
| | | e.getLongTakeProfitOrderId() != null ? e.getLongTakeProfitOrderId() : "-", |
| | | e.getShortTakeProfitOrderId() != null ? e.getShortTakeProfitOrderId() : "-", |
| | | e.hasLongStopLossOrders() ? String.join(",", e.getLongStopLossOrderIds()) : "-", |
| | |
| | | |
| | | private static void putDynamicIndices(GridElement e) { |
| | | PRICE_INDEX.put(e.getGridPrice(), e); |
| | | if (e.getLongOrderId() != null) { |
| | | LONG_ORDER_ID_INDEX.put(e.getLongOrderId(), e); |
| | | for (String oId : e.getLongOrderIds()) { |
| | | LONG_ORDER_ID_INDEX.put(oId, e); |
| | | } |
| | | if (e.getShortOrderId() != null) { |
| | | SHORT_ORDER_ID_INDEX.put(e.getShortOrderId(), e); |
| | | for (String oId : e.getShortOrderIds()) { |
| | | SHORT_ORDER_ID_INDEX.put(oId, e); |
| | | } |
| | | if (e.getLongTakeProfitOrderId() != null) { |
| | | LONG_TP_ORDER_ID_INDEX.put(e.getLongTakeProfitOrderId(), e); |
| | |
| | | this.shortTraderParam = builder.shortTraderParam; |
| | | this.upId = builder.upId; |
| | | this.downId = builder.downId; |
| | | this.longOrderId = builder.longOrderId; |
| | | this.shortOrderId = builder.shortOrderId; |
| | | this.longTakeProfitOrderId = builder.longTakeProfitOrderId; |
| | | this.shortTakeProfitOrderId = builder.shortTakeProfitOrderId; |
| | | if (builder.longOrderIds != null) this.longOrderIds.addAll(builder.longOrderIds); |
| | | if (builder.shortOrderIds != null) this.shortOrderIds.addAll(builder.shortOrderIds); |
| | | if (builder.longStopLossOrderIds != null) this.longStopLossOrderIds.addAll(builder.longStopLossOrderIds); |
| | | if (builder.shortStopLossOrderIds != null) this.shortStopLossOrderIds.addAll(builder.shortStopLossOrderIds); |
| | | } |
| | |
| | | /** 设置下一个网格编号 */ |
| | | public void setDownId(Integer downId) { this.downId = downId; } |
| | | |
| | | // ==================== 多仓挂单订单 ID ==================== |
| | | // ==================== 多仓挂单订单 ID 列表 ==================== |
| | | |
| | | /** @return 多仓挂单订单 ID */ |
| | | public String getLongOrderId() { return longOrderId; } |
| | | /** 设置多仓挂单订单 ID */ |
| | | public void setLongOrderId(String longOrderId) { this.longOrderId = longOrderId; } |
| | | /** @return 多仓挂单订单 ID 列表 */ |
| | | public List<String> getLongOrderIds() { return longOrderIds; } |
| | | /** 添加多仓挂单订单 ID */ |
| | | public void addLongOrderId(String orderId) { if (orderId != null) longOrderIds.add(orderId); } |
| | | /** 移除多仓挂单订单 ID */ |
| | | public boolean removeLongOrderId(String orderId) { return longOrderIds.remove(orderId); } |
| | | /** 清空多仓挂单订单 ID */ |
| | | public void clearLongOrderIds() { longOrderIds.clear(); } |
| | | /** @return 是否有挂单 ID(列表非空) */ |
| | | public boolean hasLongOrderIds() { return !longOrderIds.isEmpty(); } |
| | | /** @deprecated 返回最后一个订单ID,用于单订单场景的兼容 */ |
| | | @Deprecated |
| | | public String getLongOrderId() { return longOrderIds.isEmpty() ? null : longOrderIds.get(longOrderIds.size() - 1); } |
| | | /** @deprecated 添加到列表,用于兼容旧调用 */ |
| | | @Deprecated |
| | | public void setLongOrderId(String orderId) { if (orderId != null) longOrderIds.add(orderId); } |
| | | |
| | | // ==================== 空仓挂单订单 ID ==================== |
| | | // ==================== 空仓挂单订单 ID 列表 ==================== |
| | | |
| | | /** @return 空仓挂单订单 ID */ |
| | | public String getShortOrderId() { return shortOrderId; } |
| | | /** 设置空仓挂单订单 ID */ |
| | | public void setShortOrderId(String shortOrderId) { this.shortOrderId = shortOrderId; } |
| | | /** @return 空仓挂单订单 ID 列表 */ |
| | | public List<String> getShortOrderIds() { return shortOrderIds; } |
| | | /** 添加空仓挂单订单 ID */ |
| | | public void addShortOrderId(String orderId) { if (orderId != null) shortOrderIds.add(orderId); } |
| | | /** 移除空仓挂单订单 ID */ |
| | | public boolean removeShortOrderId(String orderId) { return shortOrderIds.remove(orderId); } |
| | | /** 清空空仓挂单订单 ID */ |
| | | public void clearShortOrderIds() { shortOrderIds.clear(); } |
| | | /** @return 是否有挂单 ID(列表非空) */ |
| | | public boolean hasShortOrderIds() { return !shortOrderIds.isEmpty(); } |
| | | /** @deprecated 返回最后一个订单ID,用于单订单场景的兼容 */ |
| | | @Deprecated |
| | | public String getShortOrderId() { return shortOrderIds.isEmpty() ? null : shortOrderIds.get(shortOrderIds.size() - 1); } |
| | | /** @deprecated 添加到列表,用于兼容旧调用 */ |
| | | @Deprecated |
| | | public void setShortOrderId(String orderId) { if (orderId != null) shortOrderIds.add(orderId); } |
| | | |
| | | // ==================== 多仓止盈订单 ID ==================== |
| | | |
| | |
| | | private Integer upId; |
| | | /** 下一个网格编号,默认 null(无下一级) */ |
| | | private Integer downId; |
| | | /** 多仓挂单订单 ID */ |
| | | private String longOrderId; |
| | | /** 空仓挂单订单 ID */ |
| | | private String shortOrderId; |
| | | /** 多仓挂单订单 ID 列表 */ |
| | | private List<String> longOrderIds; |
| | | /** 空仓挂单订单 ID 列表 */ |
| | | private List<String> shortOrderIds; |
| | | /** 多仓止盈订单 ID */ |
| | | private String longTakeProfitOrderId; |
| | | /** 空仓止盈订单 ID */ |
| | |
| | | public Builder upId(Integer upId) { this.upId = upId; return this; } |
| | | /** 设置下一个网格编号 */ |
| | | public Builder downId(Integer downId) { this.downId = downId; return this; } |
| | | /** 设置多仓挂单订单 ID */ |
| | | public Builder longOrderId(String longOrderId) { this.longOrderId = longOrderId; return this; } |
| | | /** 设置空仓挂单订单 ID */ |
| | | public Builder shortOrderId(String shortOrderId) { this.shortOrderId = shortOrderId; return this; } |
| | | /** 设置多仓挂单订单 ID 列表 */ |
| | | public Builder longOrderIds(List<String> longOrderIds) { this.longOrderIds = longOrderIds; return this; } |
| | | /** 设置空仓挂单订单 ID 列表 */ |
| | | public Builder shortOrderIds(List<String> shortOrderIds) { this.shortOrderIds = shortOrderIds; return this; } |
| | | /** 设置多仓止盈订单 ID */ |
| | | public Builder longTakeProfitOrderId(String longTakeProfitOrderId) { this.longTakeProfitOrderId = longTakeProfitOrderId; return this; } |
| | | /** 设置空仓止盈订单 ID */ |