Skip to content

Commit

Permalink
Renumbered examples in classic plus two new examples. Also added the
Browse files Browse the repository at this point in the history
chart screenshot.
  • Loading branch information
jimmoores committed Aug 30, 2017
1 parent cb0539f commit 8eb4425
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 55 deletions.
Expand Up @@ -20,7 +20,7 @@ private Example1() {
private void run() {
ClassicQuandlSession session = ClassicQuandlSession.create();
TabularResult tabularResult = session.getDataSet(
DataSetRequest.Builder.of("WIKI/AAPL").build());
DataSetRequest.Builder.of("WIKI/AAPL").withMaxRows(10).build());
System.out.println(tabularResult.toPrettyPrintedString());
}

Expand Down

This file was deleted.

@@ -1,14 +1,13 @@
package com.jimmoores.quandl.classic.example;

import com.jimmoores.quandl.SearchRequest;
import com.jimmoores.quandl.SearchResult;
import com.jimmoores.quandl.MetaDataRequest;
import com.jimmoores.quandl.MetaDataResult;
import com.jimmoores.quandl.classic.ClassicQuandlSession;

/**
* Example 4.
* Example 3.
*/
public final class Example4 {

/**
* Private default constructor.
*/
Expand All @@ -20,8 +19,8 @@ private Example4() {
*/
private void run() {
ClassicQuandlSession session = ClassicQuandlSession.create();
SearchResult searchResult = session.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build());
System.out.println(searchResult.toPrettyPrintedString());
MetaDataResult metaData = session.getMetaData(MetaDataRequest.of("WIKI/AAPL"));
System.out.println(metaData.toPrettyPrintedString());
}

/**
Expand Down
@@ -1,12 +1,11 @@
package com.jimmoores.quandl.classic.example;

import com.jimmoores.quandl.MetaDataResult;
import com.jimmoores.quandl.SearchRequest;
import com.jimmoores.quandl.SearchResult;
import com.jimmoores.quandl.classic.ClassicQuandlSession;

/**
* Example 5.
* Example 4.
*/
public final class Example5 {

Expand All @@ -22,13 +21,7 @@ private Example5() {
private void run() {
ClassicQuandlSession session = ClassicQuandlSession.create();
SearchResult searchResult = session.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build());
System.out.println("Current page:" + searchResult.getCurrentPage());
System.out.println("Documents per page:" + searchResult.getDocumentsPerPage());
System.out.println("Total matching documents:" + searchResult.getTotalDocuments());
for (MetaDataResult document : searchResult.getMetaDataResultList()) {
System.out.println("Quandl code " + document.getQuandlCode() + " matched");
System.out.println("Available columns are: " + document.getHeaderDefinition());
}
System.out.println(searchResult.toPrettyPrintedString());
}

/**
Expand Down
@@ -0,0 +1,42 @@
package com.jimmoores.quandl.classic.example;

import com.jimmoores.quandl.MetaDataResult;
import com.jimmoores.quandl.SearchRequest;
import com.jimmoores.quandl.SearchResult;
import com.jimmoores.quandl.classic.ClassicQuandlSession;

/**
* Example 5.
*/
public final class Example6 {

/**
* Private default constructor.
*/
private Example6() {
}

/**
* The main body of the code.
*/
private void run() {
ClassicQuandlSession session = ClassicQuandlSession.create();
SearchResult searchResult = session.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build());
System.out.println("Current page:" + searchResult.getCurrentPage());
System.out.println("Documents per page:" + searchResult.getDocumentsPerPage());
System.out.println("Total matching documents:" + searchResult.getTotalDocuments());
for (MetaDataResult document : searchResult.getMetaDataResultList()) {
System.out.println("Quandl code " + document.getQuandlCode() + " matched");
System.out.println("Available columns are: " + document.getHeaderDefinition());
}
}

/**
* Main entry point.
* @param args command line arguments
*/
public static void main(final String[] args) {
Example6 example = new Example6();
example.run();
}
}
Expand Up @@ -5,9 +5,9 @@
import com.jimmoores.quandl.classic.example.Demo;
import com.jimmoores.quandl.classic.example.Example1;
import com.jimmoores.quandl.classic.example.Example2;
import com.jimmoores.quandl.classic.example.Example3;
import com.jimmoores.quandl.classic.example.Example4;
import com.jimmoores.quandl.classic.example.Example5;
import com.jimmoores.quandl.classic.example.Example6;


// CHECKSTYLE:OFF
Expand All @@ -27,15 +27,15 @@ public void example2Test() {
}
@Test
public void example3Test() {
Example3.main(new String[] {});
Example4.main(new String[] {});
}
@Test
public void example4Test() {
Example4.main(new String[] {});
Example5.main(new String[] {});
}
@Test
public void example5Test() {
Example5.main(new String[] {});
Example6.main(new String[] {});
}
@Test
public void demoTest() {
Expand Down
Binary file added docs/tablesaw-chart.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion tablesaw/pom.xml
Expand Up @@ -31,7 +31,13 @@
<dependency>
<groupId>tech.tablesaw</groupId>
<artifactId>tablesaw-core</artifactId>
<version>0.9.0</version>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>tech.tablesaw</groupId>
<artifactId>tablesaw-plot</artifactId>
<version>0.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
@@ -0,0 +1,36 @@
package com.jimmoores.quandl.tablesaw.example;

import com.jimmoores.quandl.DataSetRequest;
import com.jimmoores.quandl.tablesaw.TableSawQuandlSession;

import tech.tablesaw.api.Table;

/**
* Example 7
*/
public class Example7 {
/**
* Private default constructor.
*/
private Example7() {
}

/**
* The main body of the code.
*/
private void run() {
TableSawQuandlSession session = TableSawQuandlSession.create();
Table table = session.getDataSet(
DataSetRequest.Builder.of("WIKI/AAPL").withMaxRows(10).build());
System.out.println(table);
}

/**
* Main entry point.
* @param args command line arguments
*/
public static void main(final String[] args) {
Example7 example = new Example7();
example.run();
}
}
@@ -0,0 +1,54 @@
package com.jimmoores.quandl.tablesaw.example;

import com.jimmoores.quandl.DataSetRequest;
import com.jimmoores.quandl.tablesaw.TableSawQuandlSession;

import tech.tablesaw.api.ShortColumn;
import tech.tablesaw.api.Table;
import tech.tablesaw.api.plot.Bar;

/**
* Example 7
*/
public class Example8 {
/**
* Private default constructor.
*/
private Example8() {
}

/**
* The main body of the code.
*/
private void run() {
TableSawQuandlSession session = TableSawQuandlSession.create();
Table table = session.getDataSet(
DataSetRequest.Builder.of("WIKI/AAPL").build());
// Create a new column containing the year
ShortColumn yearColumn = table.dateColumn("Date").year();
yearColumn.setName("Year");
table.addColumn(yearColumn);
// Create max, min and total volume tables aggregated by year
Table summaryMax = table.max("Close").by("year");
Table summaryMin = table.minimum("Close").by("year");
Table summaryVolume = table.sum("Volume").by("year");
// Create a new table from each of these
Table summary = Table.create("Summary", summaryMax.column(0), summaryMax.column(1), summaryMin.column(1), summaryVolume.column(1));
// Show the max close price as a graph.
try {
Bar.show("Max Close Price by year", summary.shortColumn("Year"), summary.numericColumn(1));
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(summary);
}

/**
* Main entry point.
* @param args command line arguments
*/
public static void main(final String[] args) {
Example8 example = new Example8();
example.run();
}
}

0 comments on commit 8eb4425

Please sign in to comment.