| | |
| | | int posSize = queryPositionSize(OkxPosMode.SHORT); |
| | | extendShortStopLoss(posSize, shortGridElement.getId()); |
| | | accumulatedShortLossCount = 0; |
| | | log.info("[OKX] 空单成交 gridId:{}, 当前持仓:{}张", filledQty, posSize); |
| | | log.info("[OKX] 空单成交 gridId:{}, 成交{}张, 当前持仓:{}张", |
| | | shortGridElement.getId(), filledQty, posSize); |
| | | |
| | | BigDecimal shortBaseQty = new BigDecimal(config.getBaseQuantity()); |
| | | BigDecimal shortGridQty = new BigDecimal(config.getQuantity()); |
| | |
| | | BigDecimal shortExcess = BigDecimal.valueOf(posSize).subtract(shortBaseQty); |
| | | 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; } |
| | | int tpGridId = shortGridElement.getId() - 2 * (i + 1); |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) { |
| | | continue; |
| | |
| | | int posSize = queryPositionSize(OkxPosMode.LONG); |
| | | extendLongStopLoss(posSize, longGridElement.getId()); |
| | | accumulatedLongLossCount = 0; |
| | | log.info("[OKX] 多单成交 gridId:{}, 当前持仓:{}张", filledQty, posSize); |
| | | log.info("[OKX] 多单成交 gridId:{}, 成交{}张, 当前持仓:{}张", |
| | | longGridElement.getId(), filledQty, posSize); |
| | | |
| | | BigDecimal longBaseQty = new BigDecimal(config.getBaseQuantity()); |
| | | BigDecimal longGridQty = new BigDecimal(config.getQuantity()); |
| | |
| | | BigDecimal longExcess = BigDecimal.valueOf(posSize).subtract(longBaseQty); |
| | | 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; } |
| | | int tpGridId = longGridElement.getId() + 2 * (i + 1); |
| | | GridElement tpElem = GridElement.findById(tpGridId); |
| | | if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) { |
| | | continue; |