@Test public void testSimpleGetDataSet() { QuandlSession session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/MSFT.csv"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/MSFT").build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
/** * The main body of the code. */ private void run() { QuandlSession quandl = QuandlSession.create(); SearchResult searchResult = quandl.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build()); System.out.println(searchResult.toPrettyPrintedString()); for (MetaDataResult metaData : searchResult.getMetaDataResultList()) { System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); } TabularResult tabularResult = null; tabularResult = quandl.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL").withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN).withTransform(Transform.NORMALIZE).build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResult)); TabularResult tabularResultMulti = quandl.getDataSets( MultiDataSetRequest.Builder.of( QuandlCodeRequest.allColumns("WIKI/AAPL"), QuandlCodeRequest.allColumns("DOE/RWTC") ).withStartDate(RECENTISH_DATE) .build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResultMulti)); MetaDataResult metaData = quandl.getMetaData(MetaDataRequest.of("WIKI/AAPL")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); MetaDataResult metaData2 = quandl.getMetaData(MultiMetaDataRequest.of("WIKI/AAPL", "DOE/RWTC", "WIKI/MSFT")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData2.getRawJSON())); }
/** * Run a set of data set requests using the provided quandl codes. * @param session the Quandl session * @param resultProcessor a result processor to ether record or check the results * @param quandlCodes a random set of Quandl codes to construct the requests from */ private void fuzzDataSetRequests(final QuandlSession session, final ResultProcessor resultProcessor, final Set<String> quandlCodes) { for (String quandlCode : quandlCodes) { DataSetRequest req = fuzz(DataSetRequest.Builder.of(quandlCode)).build(); try { @SuppressWarnings("unused") TabularResult dataSet = session.getDataSet(req); //s_logger.info(req.toString()); //s_logger.info(PrettyPrinter.toPrettyPrintedString(dataSet)); } catch (QuandlRuntimeException qre) { s_logger.warn("Caught" + qre); s_logger.info("Continuing..."); } } }
/** * The main body of the code. */ private void run() { QuandlSession session = QuandlSession.create(); TabularResult tabularResult = session.getDataSet( DataSetRequest.Builder.of("WIKI/AAPL").build()); System.out.println(tabularResult.toPrettyPrintedString()); }
@Test public void testMoreComplexGetDataSet() { QuandlSession session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?column_index=4&collapse=quarterly&transform=normalize"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
@Test public void testMostComplexGetDataSet() { QuandlSession session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?start_date=2009-01-01&end_date=2010-12-31&column_index=4&collapse=quarterly&limit=10&transform=normalize"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL") .withStartDate(LocalDate.of(2009, 1, 1)) .withEndDate(LocalDate.of(2010, 12, 31)) .withMaxRows(10) .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
@Test public void testMostComplexGetDataSetDifferentOrder() { // now try a different order QuandlSession session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?start_date=2009-01-01&end_date=2010-12-31&column_index=4&collapse=quarterly&limit=10&transform=normalize"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withStartDate(LocalDate.of(2009, 1, 1)) .withEndDate(LocalDate.of(2010, 12, 31)) .withMaxRows(10) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
/** * The main body of the code. */ private void run() { QuandlSession session = QuandlSession.create(); TabularResult tabularResult = session.getDataSet( DataSetRequest.Builder .of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withTransform(Transform.NORMALIZE) .build()); System.out.println(tabularResult.toPrettyPrintedString()); }
TabularResult tabularResult = null; try { tabularResult = getDataSet(dataSetRequest); } catch (final QuandlRuntimeException qre) { s_logger.error("Exception processing request for {}, giving up and skipping. Full request was {}",