| | |
| | | package com.xcong.excoin.rabbit.pricequeue; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xcong.excoin.common.contants.AppContants; |
| | | import com.xcong.excoin.rabbit.producer.OrderProducer; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.concurrent.PriorityBlockingQueue; |
| | | |
| | | @Slf4j |
| | |
| | | |
| | | @Autowired |
| | | OrderProducer orderProducer; |
| | | @Resource |
| | | private RedisUtils redisUtils; |
| | | |
| | | /** |
| | | * @param symbol |
| | |
| | | |
| | | } |
| | | |
| | | private void addExecType(OrderModel model) { |
| | | List<Object> orderTypes = redisUtils.lGet(AppContants.RABBIT_TYPE + model.getOrderId(), 0 , -1); |
| | | if (CollUtil.isNotEmpty(orderTypes)) { |
| | | orderTypes.add(model.getType()); |
| | | } else { |
| | | orderTypes = new ArrayList<>(); |
| | | orderTypes.add(model.getType()); |
| | | } |
| | | |
| | | redisUtils.lSet(AppContants.RABBIT_TYPE + model.getOrderId(), orderTypes, 10); |
| | | redisUtils.lSet(AppContants.MEMBER_TYPE + model.getMemberId(), orderTypes, 5); |
| | | } |
| | | |
| | | // 处理消息 正序的 包括 |
| | | // 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空 |
| | | public void dealAscPriceOrderAndSenMq(List<AscBigDecimal> list, String symbol) { |
| | |
| | | // 3:开空 7:爆仓平空 |
| | | // 9:止盈平多 12:止损平空 |
| | | for (OrderModel model : orderModelList) { |
| | | /* |
| | | 问题: 1、逐仓: 当行情大时,若设置的止损点与爆仓过于接近,则可能会出现直接爆仓,而不止损的情况 |
| | | 2、全仓: 止盈价/止损价 设置的与委托平仓价相同,需优先处理止盈/止损 |
| | | 解决: 将订单ID作为Key, 该订单执行的队列类型集合作为value, 用于在执行爆仓、委托平仓时,是否存在止盈/止损,若存在则不执行该爆仓和委托平仓 |
| | | */ |
| | | addExecType(model); |
| | | |
| | | // 止损平空 |
| | | List<OrderModel> kkzsList = new ArrayList<OrderModel>(); |
| | | // 止盈平多 |
| | |
| | | // 2:开多6:爆仓平多 |
| | | // 10:止盈平空11:止损平多 |
| | | for (OrderModel model : orderModelList) { |
| | | /* |
| | | 问题: 1、逐仓: 当行情大时,若设置的止损点与爆仓过于接近,则可能会出现直接爆仓,而不止损的情况 |
| | | 2、全仓: 止盈价/止损价 设置的与委托平仓价相同,需优先处理止盈/止损 |
| | | 解决: 将订单ID作为Key, 该订单执行的队列类型集合作为value, 用于在执行爆仓、委托平仓时,是否存在止盈/止损,若存在则不执行该爆仓和委托平仓 |
| | | */ |
| | | addExecType(model); |
| | | |
| | | // 开空止盈 |
| | | List<OrderModel> kkzyList = new ArrayList<OrderModel>(); |
| | | // 开多止损 |