Reputation: 205
I am trying to pull stock data from yahoo finance using the yahoo finance api for java. My program was working absolutely fine up until yesterday, when this piece of code just stopped working, throwing up the following errors:
SEVERE: Unparseable date: "11/17/2014"
java.text.ParseException: Unparseable date: "11/17/2014"
at java.text.DateFormat.parse(DateFormat.java:337)
at yahoofinance.Utils.parseDividendDate(Utils.java:176)
at yahoofinance.quotes.stock.StockQuotesData.getDividend(StockQuotesData.java:87)
at yahoofinance.quotes.stock.StockQuotesData.getStock(StockQuotesData.java:105)
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:336)
at yahoofinance.YahooFinance.get(YahooFinance.java:76)
at yahoofinance.YahooFinance.get(YahooFinance.java:61)
at controlp5userinterface.ControlP5UserInterface.setup(ControlP5UserInterface.java:75)
at processing.core.PApplet.handleDraw(PApplet.java:2361)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Thread.java:695)
Exception in thread "Animation Thread" java.lang.NullPointerException
at controlp5userinterface.ControlP5UserInterface.setup(ControlP5UserInterface.java:76)
at processing.core.PApplet.handleDraw(PApplet.java:2361)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Thread.java:695)
Here is my code for the section that has stopped working, I can post the complete code if it is of any help. I know that the error is in parsing the date in the yahoo finance cvs file returned but I have no idea why its happening now when it worked perfectly beforehand.
Stock[] stocks = new Stock[symbols.length];
double[] quotePrices = new double[stocks.length];
for(int i = 0; i<stocks.length; i++){
String symbol = symbols[i];
stocks[i] = YahooFinance.get(symbol); //error is here
quotePrices[i] = stocks[i].getQuote().getPrice().doubleValue();
System.out.println("Price: " + quotePrices[i]);
}
System.out.println("Finished finance import");
Upvotes: 0
Views: 444
Reputation: 71
This issue was fixed in v1.2.3 (in the meantime v1.3.0 is available, which is recommended)
Furthermore, if the library is unable to parse the dividend date, it will write an error to the log file (for example: SEVERE: Unparseable date: "11/17/2014"
), but the exception is caught and the dividend date will just be null
.
It is possible for Yahoo Finance to not return any dividend date at all, so please check if it's null
before trying to use it.
In case you encounter a problem like this, please don't hesitate to create an issue through Github.
Upvotes: 3