| | |
| | | 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()); |
| | |
| | | // 找到比当前价格还大的就是需要操作的 开多止损 |
| | | // 即最大的币当前价大 那么需要开多止损 |
| | | 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()); |
| | |
| | | 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; |
| | | } |
| | |
| | | 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); |
| | |
| | | kkzsList.add(model); |
| | | break; |
| | | default: |
| | | log.info("#price-service unknow type#"); |
| | | log.info("#price-service unknown type#"); |
| | | break; |
| | | } |
| | | |
| | |
| | | if (CollectionUtils.isNotEmpty(wtkkList)) { |
| | | orderProducer.sendLimit(JSONObject.toJSONString(wtkkList)); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(wtpdList)) { |
| | | orderProducer.sendLimitClose(JSONObject.toJSONString(wtpdList)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | // 根据不同类型发送不同消息 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); |
| | |
| | | |
| | | } |
| | | |
| | | log.info("{}", orderModelList); |
| | | if (CollectionUtils.isEmpty(orderModelList)) { |
| | | return; |
| | | } |
| | |
| | | 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); |
| | |
| | | } |
| | | if (CollectionUtils.isNotEmpty(wtkdList)) { |
| | | orderProducer.sendLimit(JSONObject.toJSONString(wtkdList)); |
| | | |
| | | } |
| | | if (CollectionUtils.isNotEmpty(wtpkList)) { |
| | | orderProducer.sendLimitClose(JSONObject.toJSONString(wtpkList)); |
| | | } |
| | | } |
| | | } |