* @throws java.io.IOException
*/
public StockPrice getStockPrice(String ticker, Timestamp virtualDate) throws IOException {
virtualDate = util.TimeKeeper.round_to_day(virtualDate);
Stock stock = Stock.find.where().eq("ticker", ticker).findUnique();
List<StockPrice> stockPrices = StockPrice.find.filter().eq("Date", virtualDate).filter(stock.getPrices());
//parse file to get updated info
//if (false) {
if (stockPrices == null || stockPrices.isEmpty()) {
//just do a week at a time for performance reasons, hence 7 meaning 7 days
DateTime fromDt = new DateTime(virtualDate.getTime());
DateTime toDt = fromDt.plusDays(7);
ICsvBeanReader beanReader = setup(ticker, fromDt, toDt);
List<StockPrice> newStockPrices = parseCSV(beanReader);
stock.getPrices().addAll(newStockPrices);
stock.update();
stockPrices = StockPrice.find.filter().eq("Date", virtualDate).filter(stock.getPrices());
}
return stockPrices.isEmpty() ? null : stockPrices.get(0);
}