| File was renamed from src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java |
| | |
| | | package com.xcong.excoin.modules.gateApi; |
| | | package com.xcong.excoin.modules.okxApi; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | |
| | | * <h3>何时填充 TraderParam</h3> |
| | | * 初始化时 {@code updateGridElements()} 为每个元素预填充 longTraderParam 和 shortTraderParam |
| | | * (含 direction/entryPrice/takeProfitPrice/quantity),订单ID字段在挂单成功后由 |
| | | * {@link GateGridTradeService} 的 4 个辅助方法写入。 |
| | | * |
| | | * <h3>使用示例</h3> |
| | | * <pre> |
| | |
| | | /** 空仓止损订单 ID */ |
| | | private String shortStopLossOrderId; |
| | | |
| | | /** 全局 ID 索引,由 {@link GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | /** 全局 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | private static final Map<Integer, GridElement> INDEX = new ConcurrentHashMap<>(); |
| | | /** 全局价格索引,由 {@link GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | /** 全局价格索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | private static final Map<BigDecimal, GridElement> PRICE_INDEX = new ConcurrentHashMap<>(); |
| | | /** 全局多仓订单 ID 索引,由 {@link GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | /** 全局多仓订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | private static final Map<String, GridElement> LONG_ORDER_ID_INDEX = new ConcurrentHashMap<>(); |
| | | /** 全局空仓订单 ID 索引,由 {@link GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | /** 全局空仓订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | private static final Map<String, GridElement> SHORT_ORDER_ID_INDEX = new ConcurrentHashMap<>(); |
| | | /** 全局多仓止盈订单 ID 索引,由 {@link GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | /** 全局多仓止盈订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | private static final Map<String, GridElement> LONG_TP_ORDER_ID_INDEX = new ConcurrentHashMap<>(); |
| | | /** 全局空仓止盈订单 ID 索引,由 {@link GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | /** 全局空仓止盈订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */ |
| | | private static final Map<String, GridElement> SHORT_TP_ORDER_ID_INDEX = new ConcurrentHashMap<>(); |
| | | /** 全局多仓止损订单 ID 索引 */ |
| | | private static final Map<String, GridElement> LONG_SL_ORDER_ID_INDEX = new ConcurrentHashMap<>(); |
| | |
| | | |
| | | /** |
| | | * 从列表中重建全局 ID 索引和价格索引。 |
| | | * 由 {@link GateConfig#setGridElements(List)} 在每次列表变更后调用。 |
| | | * 由 { GateConfig#setGridElements(List)} 在每次列表变更后调用。 |
| | | */ |
| | | public static void rebuildIndex(List<GridElement> elements) { |
| | | INDEX.clear(); |