| | |
| | | // } |
| | | // ); |
| | | |
| | | // 空仓止盈:每1张持仓对应1个止盈位,从entry网格向下逐个挂 |
| | | // 空仓止盈:超额部分挂止盈,从entry网格向下逐个挂 |
| | | int shortBaseQty = Integer.parseInt(config.getBaseQuantity()); |
| | | int shortGridQty = Integer.parseInt(config.getQuantity()); |
| | | int shortTpCount = posSize / shortGridQty; |
| | | int shortTpCount = posSize > shortBaseQty ? (posSize - shortBaseQty) / shortGridQty : 0; |
| | | |
| | | for (int i = 0; i < shortTpCount; i++) { |
| | | int tpGridId = shortGridElement.getId() - 2 * (i + 1); |
| | |
| | | // } |
| | | // ); |
| | | |
| | | // 多仓止盈:每1张持仓对应1个止盈位,从entry网格向上逐个挂 |
| | | // 多仓止盈:超额部分挂止盈,从entry网格向上逐个挂 |
| | | int longBaseQty = Integer.parseInt(config.getBaseQuantity()); |
| | | int longGridQty = Integer.parseInt(config.getQuantity()); |
| | | int longTpCount = posSize / longGridQty; |
| | | int longTpCount = posSize > longBaseQty ? (posSize - longBaseQty) / longGridQty : 0; |
| | | |
| | | for (int i = 0; i < longTpCount; i++) { |
| | | int tpGridId = longGridElement.getId() + 2 * (i + 1); |
| | |
| | | if (newEntryGrid != null) { |
| | | |
| | | GridElement cancelGridElement = GridElement.findById(newEntryGrid.getUpId()); |
| | | String quantity = cancelGridElement != null |
| | | ? cancelGridElement.getLongTraderParam().getQuantity() |
| | | : config.getBaseQuantity(); |
| | | String quantity = String.valueOf((accumulatedLongLossCount + 1) * Integer.parseInt(config.getQuantity())); |
| | | if (cancelGridElement != null && cancelGridElement.isHasLongOrder()) { |
| | | for (String longOrderId : new ArrayList<>(cancelGridElement.getLongOrderIds())) { |
| | | executor.cancelConditionalOrder(longOrderId, oid -> { |
| | |
| | | |
| | | GridElement cancelGridElement = GridElement.findById(newEntryGrid.getDownId()); |
| | | |
| | | String quantity = cancelGridElement != null |
| | | ? cancelGridElement.getShortTraderParam().getQuantity() |
| | | : config.getBaseQuantity(); |
| | | String quantity = String.valueOf((accumulatedShortLossCount + 1) * Integer.parseInt(config.getQuantity())); |
| | | /** |
| | | * 看是否有空仓挂单,有就取消 |
| | | */ |
| | |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | int posSize = Math.min(queryPositionSize(Position.ModeEnum.DUAL_LONG), longPositionSize.intValue()); |
| | | int maxPos = config.getMaxPositionSize(); |
| | | int targetAmount = sameGrid ? Integer.parseInt(config.getQuantity()) : accumulatedLongLossCount + 1; |
| | | int targetAmount = sameGrid ? Integer.parseInt(config.getQuantity()) : (accumulatedLongLossCount + 1) * Integer.parseInt(config.getQuantity()); |
| | | int addSize; |
| | | if (maxPos > 0) { |
| | | int remainingRoom = maxPos - posSize; |
| | |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | int posSize = Math.min(queryPositionSize(Position.ModeEnum.DUAL_SHORT), shortPositionSize.intValue()); |
| | | int maxPos = config.getMaxPositionSize(); |
| | | int targetAmount = sameGrid ? Integer.parseInt(config.getQuantity()) : accumulatedShortLossCount + 1; |
| | | int targetAmount = sameGrid ? Integer.parseInt(config.getQuantity()) : (accumulatedShortLossCount + 1) * Integer.parseInt(config.getQuantity()); |
| | | int addSize; |
| | | if (maxPos > 0) { |
| | | int remainingRoom = maxPos - posSize; |