| | |
| | | import com.xcong.excoin.rabbit.pricequeue.OrderModel; |
| | | import com.xcong.excoin.rabbit.producer.OrderProducer; |
| | | import com.xcong.excoin.utils.CalculateUtil; |
| | | import com.xcong.excoin.utils.ThreadPoolUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.context.annotation.DependsOn; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | |
| | | * @author helius |
| | | */ |
| | | @Slf4j |
| | | @DependsOn("springContextHolder") |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "app", name = "newest-price-update-job", havingValue = "true") |
| | | public class OrderProducerInit { |
| | |
| | | if (forceSetPrice != null) { |
| | | if (forceSetPrice.compareTo(BigDecimal.ZERO) >= 0) { |
| | | OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceSetPrice.toPlainString(), |
| | | order.getSymbol(), order.getOperateNo()); |
| | | order.getSymbol(), order.getOperateNo(), order.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |
| | |
| | | if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) { |
| | | OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), |
| | | stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | // 止盈 |
| | |
| | | if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) { |
| | | OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), |
| | | stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | |
| | |
| | | if (forceSetPrice != null) { |
| | | if (forceSetPrice.compareTo(BigDecimal.ZERO) >= 0) { |
| | | OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceSetPrice.toPlainString(), |
| | | order.getSymbol(), order.getOperateNo()); |
| | | order.getSymbol(), order.getOperateNo(), order.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |
| | |
| | | if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) { |
| | | OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(), |
| | | stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | // 止盈 |
| | |
| | | if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) { |
| | | OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(), |
| | | stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |
| | |
| | | memberEntity = memberDao.selectById(memberId); |
| | | } |
| | | |
| | | CalculateUtil.getForceSetPriceForWhole(symbol, memberEntity); |
| | | // ThreadPoolUtils.sendWholeForceClosingPrice(symbol, memberEntity); |
| | | CalculateUtil.getForceSetPriceForWhole(null, memberEntity); |
| | | } |
| | | } |
| | | |
| | |
| | | // 开多委托 |
| | | model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), |
| | | entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | |
| | | } else if (ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS == entrustType){ |
| | | model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), |
| | | entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | } else if (ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE == entrustType) { |
| | | model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), |
| | | entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | } else { |
| | | model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), |
| | | entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), |
| | | order.getSymbol()); |
| | | order.getSymbol(), order.getMemberId()); |
| | | } |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |