Class QuandlHelpers

java.lang.Object
com.illumon.iris.quandl.QuandlHelpers

public class QuandlHelpers extends Object
  • Field Details

  • Constructor Details

    • QuandlHelpers

      public QuandlHelpers()
  • Method Details

    • quandlAPIKey

      public static String quandlAPIKey()
      Returns the current Quandl API key value
      Returns:
      the API key value
    • quandlAPIKey

      public static void quandlAPIKey(String key)
      Sets the Quandl API key
      Parameters:
      key - the API key value to set
    • getZipTimeout

      public static long getZipTimeout()
    • setZipTimeout

      public static void setZipTimeout(long value)
    • execGet

      public static org.apache.http.HttpResponse execGet(String getString)
      Executes an HTTP get for the passed request string and returns the HttpResponse object.
      Parameters:
      getString - a complete URI for an HTTP get
      Returns:
      an HttpResponse object representing the connection to the HTTP server
    • getQuandl

      public static Table getQuandl(String database, String dataName) throws IOException
      Tries datatables and time series sources to find the requested Quandl database and source. No optional arguments to the Quandl API.
      Parameters:
      database - Quandl database name
      dataName - Quandl datatable or dataset name
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandl

      public static Table getQuandl(String database, String dataName, StatusCallback progress) throws IOException
      Tries datatables and time series sources to find the requested Quandl database and source. Also takes a StatusCallback object to allow status updates and/or progress bar tracking.
      Parameters:
      database - Quandl database name
      dataName - Quandl datatable or dataset name
      progress - A StatusCallback to log progress or update a progress bar
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandl

      public static Table getQuandl(String database, String dataName, String... args) throws IOException
      Tries datatables and time series sources to find the requested Quandl database and source. Also takes a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name
      dataName - Quandl datatable or dataset name
      args - Optional varargs of Quandl API arguments
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandl

      public static Table getQuandl(String database, String dataName, StatusCallback progress, String... args) throws IOException
      Tries datatables and time series sources to find the requested Quandl database and source. Also takes a StatusCallback object to allow status updates and/or progress bar tracking, and a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name
      dataName - Quandl datatable or dataset name
      progress - A StatusCallback to log progress or update a progress bar
      args - Optional varargs of Quandl API arguments
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTable

      public static Table getQuandlTable(String database, String tableName) throws IOException
      Creates a table from a Quandl datatable
      Parameters:
      database - Quandl database name
      tableName - Quandl datatable name
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTable

      public static Table getQuandlTable(String database, String tableName, StatusCallback progress) throws IOException
      Creates a table from a Quandl datatable, and also takes a StatusCallback object to update status or a progress bar.
      Parameters:
      database - Quandl database name
      tableName - Quandl datatable name
      progress - A StatusCallback to log progress or update a progress bar
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTable

      public static Table getQuandlTable(String database, String tableName, String... args) throws IOException
      Creates a table from a Quandl datatable, and also takes a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name
      tableName - Quandl datatable name
      args - Optional varargs of Quandl API arguments
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTable

      public static Table getQuandlTable(String database, String tableName, StatusCallback progress, String... args) throws IOException
      Creates a table from a Quandl datatable, and also takes a StatusCallback object to update status or a progress bar, and a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name
      tableName - Quandl datatable name
      progress - A StatusCallback to log progress or update a progress bar
      args - Optional varargs of Quandl API arguments
      Returns:
      an Iris table object
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • prepareArgs

      public static String prepareArgs(String apiKey, String... args)
      Formats the http parameters list and adds the api_key, if it's not already included in the parameters
      Parameters:
      apiKey - an apiKey to append to the HTTP arguments string, if it's not already in the passed arguments
      args - a varargs list of HTTP arguments to include the final HTTP arguments string being formatted
      Returns:
      a string of HTTP arguments to pass to the Quandl API get method
    • getQuandlTimeSeries

      public static Table getQuandlTimeSeries(String database, String dataset) throws IOException
      Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated.
      Parameters:
      database - Quandl database name
      dataset - A Quandl dataset name, list, or pattern to match
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTimeSeries

      public static Table getQuandlTimeSeries(String database, String dataset, String... args) throws IOException
      Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated. Also takes a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name
      dataset - A Quandl dataset name, list, or pattern to match
      args - a varargs list of HTTP arguments to include the final HTTP arguments string being formatted
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTimeSeries

      public static Table getQuandlTimeSeries(String database, String dataset, StatusCallback progress) throws IOException
      Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated.
      Parameters:
      database - Quandl database name
      dataset - A Quandl dataset name, list, or pattern to match
      progress - a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlTimeSeries

      public static Table getQuandlTimeSeries(String database, String dataset, StatusCallback progress, String... args) throws IOException
      Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated. Also takes a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name
      dataset - A Quandl dataset name, list, or pattern to match
      progress - a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.
      args - a varargs list of HTTP arguments to include the final HTTP arguments string being formatted
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
      RuntimeException - if dataset information can't be retrieved.
    • readQuandlZippedStream

      public static InputStream readQuandlZippedStream(InputStream source) throws IOException
      Reads the first file (normally the only file) from inputstream representing a zipped file. This is used to handle, in-memory, zipped content downloaded from the Quandl API.
      Parameters:
      source - InputStream providing a zipped package, normally containing just one file
      Returns:
      InputStream representing the first file from the zipped stream (source), or null if there is no file in the source InputStream.
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlCsvFile

      public static void getQuandlCsvFile(org.apache.http.HttpResponse response, String httpGetString, StatusCallback progress, File csvFile)
      Downloads a Quandl CSV file based on the http get string passed in, and takes a StatusCallback object to update status and/or a progress bar, and a File object to write the downloaded data to.
      Parameters:
      response - an HttpResponse object holding the response from the Quandl API server
      httpGetString - the HTTP get string that was passed when calling the Quandl API
      progress - a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.
      csvFile - a File object to which the downloaded CSV should be written
    • getQuandlCsvStream

      public static InputStream getQuandlCsvStream(org.apache.http.HttpResponse response, String httpGetString, StatusCallback progress)
      Downloads a Quandl CSV file based on the http get string passed in, and takes a StatusCallback object to update status and/or a progress bar, and a File object to write the downloaded data to.
      Parameters:
      response - an HttpResponse object holding the response from the Quandl API server
      httpGetString - the HTTP get string that was passed when calling the Quandl API. If httpGetString is NULL, the results are expected to be un-zipped.
      progress - a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.
      Returns:
      a InputStream object providing access to the CSV data
    • getQuandlDatasets

      public static Table getQuandlDatasets(String database) throws IOException
      Returns a table of Quandl dataset catalog information for the specified Quandl database.
      Parameters:
      database - Quandl database name for which to retrieve catalog information
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlDatasets

      public static Table getQuandlDatasets(String database, StatusCallback progress) throws IOException
      Returns a table of Quandl dataset catalog information for the specified Quandl database. Also takes a StatusCallback object to update status or a progress bar.
      Parameters:
      database - Quandl database name for which to retrieve catalog information
      progress - a StatusCallback that can be used to log progress events and/or update a progress bar
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlDatasets

      public static Table getQuandlDatasets(String database, String dataset, String... args) throws IOException
      Returns a table of Quandl dataset catalog information for the specified Quandl database. Also takes a list of optional arguments to pass to the Quandl API.
      Parameters:
      database - Quandl database name for which to retrieve catalog information
      dataset - A Quandl dataset name, list, or pattern to match
      args - a varargs list of HTTP arguments to include the final HTTP arguments string being formatted
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems
    • getQuandlDatasets

      public static Table getQuandlDatasets(String database, String dataset, StatusCallback progress, String... args) throws IOException
      Returns a table of Quandl dataset catalog information for the specified Quandl database. Also takes a list of optional arguments to pass to the Quandl API, and a StatusCallback object to update status or a progress bar.
      Parameters:
      database - Quandl database name for which to retrieve catalog information
      dataset - A Quandl dataset name, list, or pattern to match
      progress - a StatusCallback that can be used to log progress events and/or update a progress bar
      args - a varargs list of HTTP arguments to include the final HTTP arguments string being formatted
      Returns:
      an Iris table
      Throws:
      IOException - if HTTP download or file/stream handling calls encounter problems