| | |
| | | int shortExcessCount = shortExcess.divide(shortGridQty, 0, RoundingMode.DOWN).intValue(); |
| | | for (int i = 0; i < shortExcessCount; i++) { |
| | | int tpGridId = shortGridElement.getId() - 2 - i; |
| | | if (i > 0){ |
| | | tpGridId = tpGridId - 1; |
| | | } |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) { |
| | | continue; |
| | |
| | | int longExcessCount = longExcess.divide(longGridQty, 0, RoundingMode.DOWN).intValue(); |
| | | for (int i = 0; i < longExcessCount; i++) { |
| | | int tpGridId = longGridElement.getId() + 2 + i; |
| | | if (i > 0){ |
| | | tpGridId = tpGridId + 1; |
| | | } |
| | | |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) { |
| | | continue; |
| | |
| | | if (span <= 0) { |
| | | return; |
| | | } |
| | | |
| | | // 检查是否还有剩余止盈单,只有多空止盈全部清空才继续 |
| | | if (GridElement.getLongTakeProfitCount() > 0 || GridElement.getShortTakeProfitCount() > 0) { |
| | | log.info("[Gate] 尚有未触发止盈单, 暂不检查跨度重启 longTpCount:{}, shortTpCount:{}", |
| | | GridElement.getLongTakeProfitCount(), GridElement.getShortTakeProfitCount()); |
| | | return; |
| | | } |
| | | |
| | | BigDecimal step = config.getStep(); |
| | | if (step == null || step.compareTo(BigDecimal.ZERO) == 0) { |
| | | return; |
| | |
| | | .gridRate(new BigDecimal("0.004")) |
| | | .expectedProfit(new BigDecimal("25")) |
| | | .maxLoss(new BigDecimal("15")) |
| | | .baseQuantity("39") |
| | | .quantity("13") |
| | | .baseQuantity("15") |
| | | .quantity("15") |
| | | .restartGridSpan(2) |
| | | .maxPositionSize(2) |
| | | .priceScale(2) |
| | |
| | | return SHORT_TP_ORDER_ID_INDEX.get(orderId); |
| | | } |
| | | |
| | | /** @return 当前多仓止盈单数量 */ |
| | | public static int getLongTakeProfitCount() { return LONG_TP_ORDER_ID_INDEX.size(); } |
| | | |
| | | /** @return 当前空仓止盈单数量 */ |
| | | public static int getShortTakeProfitCount() { return SHORT_TP_ORDER_ID_INDEX.size(); } |
| | | |
| | | /** |
| | | * 根据多仓止损订单 ID 快速查找网格元素(O(1))。 |
| | | */ |