Generation

testsMon, 19 Dec 2022

public static String buildMessageStockPrice(final List<StockDTO> stocks){ StringBuilder message = new StringBuilder();DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");stocks.forEach(stock -> {message.append(LocalDateTime.now().format(dateTimeFormatter)); message.append("\n\n"); message.append(stock.getSymbol()); message.append("\n\n"); message.append("Open Price -> "); message.append(stock.getOpenDayPrice()); message.append("\n\n"); message.append("Close Price -> "); message.append(stock.getCloseDayPrice()); message.append("\n\n"); message.append("Low Price -> "); message.append(stock.getLowDayPrice()); message.append("\n\n"); message.append("High Price -> "); message.append(stock.getHighDayPrice()); message.append("\n\n"); message.append("\n\n"); }); return message.toString();}

public List<StockDTO> getStocks() { List<StockDTO> stocks = new ArrayList<>(); try { YqlQuery query = new YqlQueryBuilder().query("select * from yahoo.finance.quoteslist where symbol in (\"" + getSymbols() + "\")") .format(YqlFormat.JSON).createQuery(); QueryResult queryResult = yahooFinance.executeQuery(query); StockWrapper stockWrapper = queryResult.getQuery().getResults().getAsJsonObject(GsonFactory.getDefaultInstance(), StockWrapper.class); stockWrapper.getStock().forEach(stock -> { StockDTO stockDTO = new StockDTO(); stockDTO.setSymbol(stock.getSymbol()); stockDTO.setName(stock.getName()); stockDTO.setOpenDayPrice(stock.getOpenDayPrice()); stockDTO.setCloseDayPrice(stock.getCloseDayPrice()); stockDTO.set

Questions about programming?Chat with your personal AI assistant