| | |
| | | marketDataOut.setSpread(profitPercentage.setScale(4, RoundingMode.DOWN).toPlainString()); // 设置利润百分比 |
| | | marketDataOut.setBuyPrice(buyPrice.toPlainString()); // 设置买入价格 |
| | | marketDataOut.setSellPrice(sellPrice.toPlainString()); // 设置卖出价格 |
| | | marketDataOut.setBuyNumber(markets1.getBids().getV().toPlainString()); // 设置买入数量 |
| | | marketDataOut.setSellNumber(markets2.getAsks().getV().toPlainString()); // 设置卖出数量 |
| | | marketDataOut.setBuyNumber(markets1.getBids().getV().setScale(4, RoundingMode.HALF_UP).toPlainString()); // 设置买入数量 |
| | | marketDataOut.setSellNumber(markets2.getAsks().getV().setScale(4, RoundingMode.HALF_UP).toPlainString()); // 设置卖出数量 |
| | | marketDataOut.setBuyTotalPrice((markets1.getBids().getP().multiply(markets1.getBids().getV())).setScale(0, RoundingMode.HALF_UP).toPlainString()); // 设置买入总价 |
| | | marketDataOut.setSellTotalPrice((markets2.getAsks().getP().multiply(markets2.getAsks().getV())).setScale(0,RoundingMode.HALF_UP).toPlainString()); // 设置卖出总价 |
| | | marketDataOut.setServceTime(formattedDateTime); // 设置服务时间 |
| | |
| | | /** |
| | | * 同步mexc交易所交易对 |
| | | */ |
| | | // @Scheduled(cron = "0 0/30 * * * ?") |
| | | @Scheduled(cron = "0 0/30 * * * ?") |
| | | // @Scheduled(cron = "0/10 * * * * ?") |
| | | public void syncCurrency() { |
| | | // 使用Lock来确保同步 |
| | |
| | | // log.info("距离上次发送消息时间未达到指定间隔,不发送消息。"); |
| | | } |
| | | }else{ |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | map.put("status",1); |
| | | pushMessage(session,JSONUtil.toJsonStr(map)); |
| | | closeSession(session,"没有订阅消息"); |
| | | pushMessage(session,"没有订阅消息"); |
| | | } |
| | | } |
| | | private static final Gson gson = new Gson(); |
| | |
| | | log.error("强制断开连接----异常: {}", e.getMessage()); |
| | | } |
| | | wsServers.remove(this); |
| | | log.info("客户端未及时发送订阅消息,断开连接"); |
| | | log.info(reason); |
| | | } |
| | | } |