Helius
2020-08-26 5fdd4b505c388ba585b55feacf978f87d7f3e592
src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java
@@ -34,10 +34,8 @@
        List<AscBigDecimal> list = new ArrayList<AscBigDecimal>();
        // 找到所有比当前价格大的 是需要操作的
        if (b != null && b.compareTo(now) <= 0) {
            log.info("--->{}", b.getValue());
            // 可以操作
            System.out.println("当前价格:" + price + "---正序---" + "队列价格:" + b.getValue().toPlainString() + " time:" + new Date());
            log.info("--->>>>{}", queue.peek().getValue());
            while (queue.peek() != null && queue.peek().compareTo(now) <= 0) {
                // 可以发送消息操作
                list.add(queue.remove());
@@ -61,11 +59,9 @@
        // 找到比当前价格还大的就是需要操作的 开多止损
        // 即最大的币当前价大 那么需要开多止损
        if (b != null && b.compareTo(now) <= 0) {
            log.info("--->{}", b.getValue());
            // 可以操作
            System.out.println("当前价格:" + price + "---倒序操作---" + "队列:" + b.getValue().toPlainString() + " time:" + new Date());
            log.info("--->>>>{}", queue.peek().getValue());
            while (queue.peek() != null && queue.peek().compareTo(now) <= 0) {
                // 可以发送消息操作
                list.add(queue.remove());
@@ -86,20 +82,18 @@
            List<OrderModel> orderModelList = new ArrayList<OrderModel>();
            // 3 正序
            Map<String, List<OrderModel>> orderMap = PricePriorityQueue.getOrderMap(symbol, 3);
            log.info("--->{}", JSONObject.toJSONString(orderMap));
            // 根据价格查询到对应的订单
            for (AscBigDecimal asc : list) {
                String key = asc.getValue().toPlainString();
                log.info("------>>>>>{}", key);
                assert orderMap != null;
                log.info("======={}", orderMap.containsKey(key));
                log.info("----->->{}, --> {}", JSONObject.toJSONString(orderMap), key);
                if (orderMap.containsKey(key)) {
                    orderModelList.addAll(orderMap.get(key));
                    orderMap.remove(key);
                }
            }
            log.info("{}", orderModelList);
            log.info("------>{}", JSONObject.toJSONString(orderModelList));
            if (CollectionUtils.isEmpty(orderModelList)) {
                return;
            }
@@ -117,9 +111,14 @@
                List<OrderModel> bcList = new ArrayList<OrderModel>();
                // 开空
                List<OrderModel> wtkkList = new ArrayList<OrderModel>();
                // 委托平多
                List<OrderModel> wtpdList = new ArrayList<>();
                switch (model.getType()) {
                    case 3:
                        wtkkList.add(model);
                        break;
                    case 4:
                        wtpdList.add(model);
                        break;
                    case 7:
                        bcList.add(model);
@@ -131,7 +130,7 @@
                        kkzsList.add(model);
                        break;
                    default:
                        log.info("#price-service unknow type#");
                        log.info("#price-service unknown type#");
                        break;
                }
@@ -150,6 +149,9 @@
                if (CollectionUtils.isNotEmpty(wtkkList)) {
                    orderProducer.sendLimit(JSONObject.toJSONString(wtkkList));
                }
                if (CollectionUtils.isNotEmpty(wtpdList)) {
                    orderProducer.sendLimitClose(JSONObject.toJSONString(wtpdList));
                }
            }
        }
    }
@@ -161,13 +163,11 @@
            // 根据不同类型发送不同消息  1 倒序 2  正序
            List<OrderModel> orderModelList = new ArrayList<OrderModel>();
            Map<String, List<OrderModel>> orderMap = PricePriorityQueue.getOrderMap(symbol, 2);
            log.info("--->{}", JSONObject.toJSONString(orderMap));
            // 根据价格查询到对应的订单
            for (DescBigDecimal desc : list) {
                String key = desc.getValue().toPlainString();
                log.info("------>>>>>{}", key);
                assert orderMap != null;
                log.info("======={}", orderMap.containsKey(key));
                log.info("----->->{}, --> {}", JSONObject.toJSONString(orderMap), key);
                if (orderMap.containsKey(key)) {
                    orderModelList.addAll(orderMap.get(key));
                    orderMap.remove(key);
@@ -175,7 +175,6 @@
            }
            log.info("{}", orderModelList);
            if (CollectionUtils.isEmpty(orderModelList)) {
                return;
            }
@@ -193,9 +192,14 @@
                List<OrderModel> bcList = new ArrayList<OrderModel>();
                // 开多委托
                List<OrderModel> wtkdList = new ArrayList<OrderModel>();
                // 委托平空
                List<OrderModel> wtpkList = new ArrayList<>();
                switch (model.getType()) {
                    case 2:
                        wtkdList.add(model);
                        break;
                    case 5:
                        wtpkList.add(model);
                        break;
                    case 6:
                        bcList.add(model);
@@ -224,7 +228,9 @@
                }
                if (CollectionUtils.isNotEmpty(wtkdList)) {
                    orderProducer.sendLimit(JSONObject.toJSONString(wtkdList));
                }
                if (CollectionUtils.isNotEmpty(wtpkList)) {
                    orderProducer.sendLimitClose(JSONObject.toJSONString(wtpkList));
                }
            }
        }