sstrickx / yahoofinance-api

Java Client API for Yahoo Finance
MIT License
499 stars 219 forks source link

Proposed changes #132

Closed amcelroy closed 5 years ago

amcelroy commented 6 years ago

Changed pom.xml: updated com.fastercml.jackson.core->jackson-databind to 2.9.6 from 2.9.0 Added the Serializable interface to Stock, HistoricalQuote, StockDividend, StockQuote, StockStats

The update to serializable is useful to save the data using ObjectInputStream and ObjectOutputStream to develop algorithms within the framework of the yahoofinance-api without having to re-query the Yahoo server each time.

Example to use:

Stock intel = YahooFinance.get("INTC", from, to, Interval.MONTHLY);
String fileName= System.getProperty("user.dir") + "\\Intel.java_object";
FileOutputStream fos = new FileOutputStream(fileName);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(intel);
oos.close();

FileInputStream fis = new FileInputStream(fileName);
ObjectInputStream ois = new ObjectInputStream(fis);
Stock savedStock = (Stock)ois.readObject();
ois.close();
amcelroy commented 6 years ago

Also added an interface and example class to filter HistoricalQuote data. See MovingAverage for how to apply it.