| | |
| | | for (int i = 0; i < shortTpCount; i++) { |
| | | int tpGridId = shortGridElement.getId() - 2 * (i + 1); |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) { |
| | | // 用 takeProfitPlaced 做同步标记,避免异步回调未执行时重复挂单 |
| | | if (tpElem == null || tpElem.getShortTraderParam().isTakeProfitPlaced()) { |
| | | continue; |
| | | } |
| | | tpElem.getShortTraderParam().setTakeProfitPlaced(true); |
| | | BigDecimal tpPrice = tpElem.getGridPrice(); |
| | | int finalTpGridId = tpGridId; |
| | | executor.placeTakeProfit( |
| | |
| | | for (int i = 0; i < longTpCount; i++) { |
| | | int tpGridId = longGridElement.getId() + 2 * (i + 1); |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) { |
| | | // 用 takeProfitPlaced 做同步标记,避免异步回调未执行时重复挂单 |
| | | if (tpElem == null || tpElem.getLongTraderParam().isTakeProfitPlaced()) { |
| | | continue; |
| | | } |
| | | tpElem.getLongTraderParam().setTakeProfitPlaced(true); |
| | | BigDecimal tpPrice = tpElem.getGridPrice(); |
| | | int finalTpGridId = tpGridId; |
| | | executor.placeTakeProfit( |
| | |
| | | for (GridElement e : config.getGridElements()) { |
| | | String tpId = e.getLongTakeProfitOrderId(); |
| | | if (tpId != null) { |
| | | e.getLongTraderParam().setTakeProfitPlaced(false); |
| | | e.setLongTakeProfitOrderId(null); |
| | | executor.cancelConditionalOrder(tpId, oid -> {}); |
| | | } |
| | |
| | | for (GridElement e : config.getGridElements()) { |
| | | String tpId = e.getShortTakeProfitOrderId(); |
| | | if (tpId != null) { |
| | | e.getShortTraderParam().setTakeProfitPlaced(false); |
| | | e.setShortTakeProfitOrderId(null); |
| | | executor.cancelConditionalOrder(tpId, oid -> {}); |
| | | } |