| | |
| | | if (shortGridElement.isHasShortOrder() && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0") ){ |
| | | int filledQty = Integer.parseInt(shortGridElement.getShortTraderParam().getQuantity()); |
| | | shortEntryTraderIdParam(shortGridElement, null, false); |
| | | extendShortStopLoss(filledQty); |
| | | extendShortStopLoss(filledQty,shortGridElement.getId()); |
| | | log.info("[Gate] 空单成交 gridId:{}", filledQty); |
| | | |
| | | // 空仓持仓超过baseQuantity时,从gridId-2开始向外追挂止盈 |
| | |
| | | |
| | | int filledQty = Integer.parseInt(longGridElement.getLongTraderParam().getQuantity()); |
| | | longEntryTraderIdParam(longGridElement, null, false); |
| | | extendLongStopLoss(filledQty); |
| | | extendLongStopLoss(filledQty,longGridElement.getId()); |
| | | log.info("[Gate] 多单成交 gridId:{}", filledQty); |
| | | |
| | | // 多仓持仓超过baseQuantity时,从gridId+2开始向外追挂止盈 |
| | |
| | | |
| | | BigDecimal baseQuantity = new BigDecimal(config.getBaseQuantity()); |
| | | BigDecimal subtract = baseQuantity.subtract(longPositionSize); |
| | | String size = new BigDecimal(config.getQuantity()).add(new BigDecimal("1")).toString(); |
| | | if (subtract.compareTo(BigDecimal.ZERO) >=0){ |
| | | size = subtract.add(new BigDecimal("1")).toString(); |
| | | String size = new BigDecimal(config.getQuantity()).add(new BigDecimal(config.getQuantity())).toString(); |
| | | if (subtract.compareTo(BigDecimal.ZERO) > 0){ |
| | | size = subtract.add(new BigDecimal(config.getQuantity())).toString(); |
| | | } |
| | | log.info("[Gate] 多仓止损触发 gridId:{}, 在gridId:{}挂{}基础张多单", |
| | | gridId, newEntryGridId, size); |
| | |
| | | |
| | | BigDecimal baseQuantity = new BigDecimal(config.getBaseQuantity()); |
| | | BigDecimal subtract = baseQuantity.subtract(shortPositionSize); |
| | | String size = new BigDecimal(config.getQuantity()).add(new BigDecimal("1")).toString(); |
| | | if (subtract.compareTo(BigDecimal.ZERO) >=0){ |
| | | size = subtract.add(new BigDecimal("1")).toString(); |
| | | |
| | | String size = new BigDecimal(config.getQuantity()).add(new BigDecimal(config.getQuantity())).toString(); |
| | | if (subtract.compareTo(BigDecimal.ZERO) > 0){ |
| | | size = subtract.add(new BigDecimal(config.getQuantity())).toString(); |
| | | } |
| | | log.info("[Gate] 空仓止损触发 gridId:{}, 在gridId:{}挂{}基础张空单", |
| | | gridId, newEntryGridId, size); |
| | |
| | | } |
| | | } |
| | | |
| | | private void extendLongStopLoss(int filledQty) { |
| | | private void extendLongStopLoss(int filledQty,int gridId) { |
| | | int furthestSlId = 0; |
| | | for (GridElement e : config.getGridElements()) { |
| | | if (e.getLongStopLossOrderId() != null && e.getId() < furthestSlId) { |
| | |
| | | } |
| | | } |
| | | if (furthestSlId == 0) { |
| | | furthestSlId = -11; |
| | | furthestSlId = gridId; |
| | | } |
| | | log.info("[Gate] 多仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty); |
| | | for (int i = 0; i < filledQty; i++) { |
| | |
| | | } |
| | | } |
| | | |
| | | private void extendShortStopLoss(int filledQty) { |
| | | private void extendShortStopLoss(int filledQty, int gridId) { |
| | | int furthestSlId = 0; |
| | | for (GridElement e : config.getGridElements()) { |
| | | if (e.getShortStopLossOrderId() != null && e.getId() > furthestSlId) { |
| | |
| | | } |
| | | } |
| | | if (furthestSlId == 0) { |
| | | furthestSlId = 11; |
| | | furthestSlId = gridId; |
| | | } |
| | | log.info("[Gate] 空仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty); |
| | | for (int i = 0; i < filledQty; i++) { |