I want to parse the data returned by Yahoo Finance API that is in CSV format. I want the output in company name: stock price
format. I have downloaded the Yahoo API example, the code is below:
String[] symbols = new String[] {"INTC", "BABA", "TSLA", "AIR.PA", "YHOO"};
Map<String, Stock> stocks = YahooFinance.get(symbols);
output:
INFO: Parsing CSV line: N/A,\"INTC\",\"USD\",N/A,N/A,N/A,\"INTC\",100,\"INTC\",N/A,N/A,\"INTC\",500,\"INTC\",32.35,\"INTC\",N/A,\"INTC\",\"4/23/2015\",\"4:00pm\",N/A,N/A,N/A,N/A,N/A,32348700,N/A,N/A,31.61,34.01,\"INTC\",4736000000,\"INTC\",\"INTC\",N/A,\"INTC\",153.21B,\"INTC\",4730885000,\"INTC\",\"6/1/2015\",N/A,N/A,N/A,N/A,2.16,0.59,2.40,N/A,1.82,2.78,2.77,11.77,55.87B,24.19B,34.95 Apr 24, 2015 6:14:56 PM yahoofinance.quotes.QuotesRequest getResult
I want only the price of that company.
The output you are showing is the logging of the API.
You have all the requested Stock objects available in your stocks
variable. If you want to print the price for each of them, you should do something like this:
String[] symbols = new String[] {"INTC", "BABA", "TSLA", "AIR.PA", "YHOO"};
Map<String, Stock> stocks = YahooFinance.get(symbols);
for(Stock s : stocks.values()) {
System.out.println(s.getName() + ": " + s.getQuote().getPrice());
}
Check out the javadoc to see which objects and methods are available in the API.