| | |
| | | int closeType; |
| | | if (holdOrderEntity.getOpeningType() == ContractHoldOrderEntity.OPENING_TYPE_MORE) { |
| | | // 开多, 若委托价低于当前价则立即成交 |
| | | if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) <= 0) { |
| | | WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | } |
| | | // if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) <= 0) { |
| | | // WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | // wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | // wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | // return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | // } |
| | | |
| | | closeType = ContractOrderEntity.ORDER_TYPE_CLOSE_MORE; |
| | | } else { |
| | | // 开空, 若委托价高于当前价则立即成交 |
| | | if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) >= 0) { |
| | | WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | } |
| | | // if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) >= 0) { |
| | | // WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | // wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | // wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | // return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | // } |
| | | |
| | | closeType = ContractOrderEntity.ORDER_TYPE_CLOSE_LESS; |
| | | } |
| | |
| | | if (i > 0) { |
| | | // 发送委托消息 |
| | | if (holdOrderEntity.getOpeningType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { |
| | | OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } else { |
| | | OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |