| | |
| | | * @param buyTradePlate sellTradePlate |
| | | */ |
| | | public void sendTradePlateMessage(TradePlate buyTradePlate, TradePlate sellTradePlate) { |
| | | //防止并发引起数组越界,造成盘口倒挂 TODO |
| | | //防止并发引起数组越界,造成盘口倒挂 |
| | | List<List<BigDecimal>> plate; |
| | | List<BigDecimal> plateItem; |
| | | TradePlateModel tradePlateModel = new TradePlateModel(); |
| | |
| | | if (buyTradePlate != null && buyTradePlate.getItems() != null) { |
| | | plate = new ArrayList<>(); |
| | | LinkedList<TradePlateItem> items = buyTradePlate.getItems(); |
| | | for (TradePlateItem item : items) { |
| | | for (int i = items.size() - 1; i >= 0; i--) { |
| | | plateItem = new ArrayList<>(2); |
| | | BigDecimal price = item.getPrice(); |
| | | BigDecimal amount = item.getAmount(); |
| | | BigDecimal price = items.get(i).getPrice(); |
| | | BigDecimal amount = items.get(i).getAmount(); |
| | | plateItem.add(price); |
| | | plateItem.add(amount); |
| | | plate.add(plateItem); |
| | |
| | | if (sellTradePlate != null && sellTradePlate.getItems() != null) { |
| | | plate = new ArrayList<>(); |
| | | LinkedList<TradePlateItem> items = sellTradePlate.getItems(); |
| | | for (TradePlateItem item : items) { |
| | | for (int i = items.size() - 1; i >= 0; i--) { |
| | | plateItem = new ArrayList<>(2); |
| | | BigDecimal price = item.getPrice(); |
| | | BigDecimal amount = item.getAmount(); |
| | | BigDecimal price = items.get(i).getPrice(); |
| | | BigDecimal amount = items.get(i).getAmount(); |
| | | plateItem.add(price); |
| | | plateItem.add(amount); |
| | | plate.add(plateItem); |
| | |
| | | tradePlateModel.setSell(plate); |
| | | } |
| | | |
| | | // 盘口发生变化通知TODO |
| | | |
| | | // 盘口发生变化通知 |
| | | exchangeProducer.sendPlateMsg(JSON.toJSONString(tradePlateModel)); |
| | | } |
| | | |
| | |
| | | * @param |
| | | */ |
| | | public String sendTradePlateMessage() { |
| | | //防止并发引起数组越界,造成盘口倒挂 TODO |
| | | //防止并发引起数组越界,造成盘口倒挂 |
| | | List<List<BigDecimal>> plate; |
| | | List<BigDecimal> plateItem; |
| | | TradePlateModel tradePlateModel = new TradePlateModel(); |
| | |
| | | |
| | | // 盘口发生变化通知TODO |
| | | return JSON.toJSONString(tradePlateModel); |
| | | //exchangeProducer.sendPlateMsg(JSON.toJSONString(tradePlateModel)); |
| | | } |
| | | |
| | | /** |