try {
final Collection<LoadedMarketData> result =
new ArrayList<LoadedMarketData>();
final URL url = buildURL(ticker, from, to);
final InputStream is = url.openStream();
final ReadCSV csv = new ReadCSV(is, true, CSVFormat.ENGLISH);
while (csv.next()) {
final Date date = csv.getDate("date");
final double adjClose = csv.getDouble("adj close");
final double open = csv.getDouble("open");
final double close = csv.getDouble("close");
final double high = csv.getDouble("high");
final double low = csv.getDouble("low");
final double volume = csv.getDouble("volume");
final LoadedMarketData data =
new LoadedMarketData(date, ticker);
data.setData(MarketDataType.ADJUSTED_CLOSE, adjClose);
data.setData(MarketDataType.OPEN, open);
data.setData(MarketDataType.CLOSE, close);
data.setData(MarketDataType.HIGH, high);
data.setData(MarketDataType.LOW, low);
data.setData(MarketDataType.OPEN, open);
data.setData(MarketDataType.VOLUME, volume);
result.add(data);
}
csv.close();
is.close();
return result;
} catch (final IOException e) {
throw new LoaderError(e);
}