| | |
| | | int shortGridQty = Integer.parseInt(config.getQuantity()); |
| | | int shortTpCount = posSize > shortBaseQty ? (posSize - shortBaseQty) / shortGridQty : 0; |
| | | |
| | | int tpSpan = config.getTakeProfitGridSpan(); |
| | | for (int i = 0; i < shortTpCount; i++) { |
| | | int tpGridId = shortGridElement.getId() - 2 * (i + 1); |
| | | int tpGridId = shortGridElement.getId() - tpSpan * (i + 1); |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | // 用 takeProfitPlaced 做同步标记,避免异步回调未执行时重复挂单 |
| | | if (tpElem == null || tpElem.getShortTraderParam().isTakeProfitPlaced()) { |
| | |
| | | int longGridQty = Integer.parseInt(config.getQuantity()); |
| | | int longTpCount = posSize > longBaseQty ? (posSize - longBaseQty) / longGridQty : 0; |
| | | |
| | | int tpSpan = config.getTakeProfitGridSpan(); |
| | | for (int i = 0; i < longTpCount; i++) { |
| | | int tpGridId = longGridElement.getId() + 2 * (i + 1); |
| | | int tpGridId = longGridElement.getId() + tpSpan * (i + 1); |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | // 用 takeProfitPlaced 做同步标记,避免异步回调未执行时重复挂单 |
| | | if (tpElem == null || tpElem.getLongTraderParam().isTakeProfitPlaced()) { |