Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renumbered examples in classic plus two new examples. Also added the
chart screenshot.
- Loading branch information
Showing
10 changed files
with
151 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
core/src/test/java/com/jimmoores/quandl/classic/example/Example3.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/src/test/java/com/jimmoores/quandl/classic/example/Example6.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tablesaw/src/test/java/com/jimmoores/quandl/tablesaw/example/Example7.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
tablesaw/src/test/java/com/jimmoores/quandl/tablesaw/example/Example8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |