YahooFinanceWebClient implements ContractDataSource<FundamentalData>, HistoricalDataSource { public FundamentalData getDataSnapshot(Contract contract) throws IOException, DataUnavailableException { StringBuilder reqUrl = new StringBuilder(fundamentalDataUrl); reqUrl.append("?s=").append(contract.getSymbol()); reqUrl.append("&f=va2j1r"); BufferedReader content = new BufferedReader(new InputStreamReader(new URL(reqUrl.toString()).openStream())); String fields[] = content.readLine().split(","); content.close(); FundamentalData data = new FundamentalData(); try { data.setVolume(NumberFormat.getNumberInstance().parse(fields[0]).longValue()); } catch (ParseException e) { log.warn("Volume parsing failed", e); } try { data.setAvgVolume(NumberFormat.getNumberInstance().parse(fields[1]).longValue()); } catch (ParseException e) { log.warn("Avg volume parsing failed", e); } try { data.setMarketCap(parseMillions(fields[2])); } catch (ParseException e) { log.warn("Market cap parsing failed", e); } try { data.setPeRatio(NumberFormat.getNumberInstance().parse(fields[2]).doubleValue()); } catch (ParseException e) { log.warn("P/E ratio parsing failed", e); } return data; }  FundamentalData getDataSnapshot(Contract contract); OHLC[] getHistoricalData(Contract contract, Date endDate, int numPeriods, int periodUnit); void close();  }
@Test public void testFundamentalData() throws Exception { FundamentalData data = client.getDataSnapshot(Contract.stock("BAC")); assertNotNull(data); System.out.println(data); }