| | |
| | | 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开始向外追挂止盈 |
| | |
| | | // ); |
| | | // } |
| | | |
| | | int shortTime = Integer.parseInt(config.getBaseQuantity()) + 1; |
| | | int shortTime = Integer.parseInt(config.getBaseQuantity()) / Integer.parseInt(config.getQuantity()) + 1; |
| | | for (int id = 2; id <= shortTime; id++) { |
| | | GridElement elem = GridElement.findById(id); |
| | | if (elem == null) { |
| | |
| | | } |
| | | |
| | | |
| | | int longTime = Integer.parseInt(config.getBaseQuantity()) + 1; |
| | | int longTime = Integer.parseInt(config.getBaseQuantity()) / Integer.parseInt(config.getQuantity()) + 1; |
| | | for (int id = -2; id >= -longTime; id--) { |
| | | GridElement elem = GridElement.findById(id); |
| | | if (elem == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | 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++) { |