Forex Data API Docs

The API documentation below is based on the Java data API, however all APIs share the same basic methods and functionality so this serves as a general reference. Also see the examples provided with each API package for language specific idioms.



net.forexfeed
Class ForexFeed

Object
  net.forexfeed.ForexFeed

public class ForexFeed
extends Object


Constructor Summary
ForexFeed(String access_key)
           
ForexFeed(String access_key, String symbol)
           
ForexFeed(String access_key, String symbol, int interval)
           
ForexFeed(String access_key, String symbol, int interval, int periods)
           
ForexFeed(String access_key, String symbol, int interval, int periods, String price)
           
 
Method Summary
 String getAccessKey()
          Gets the Access key being used for all data operations.
 String getAccessPeriod()
          Get the length of the access period, usually a value of day for a 24 hour cycle.
 String getAccessPeriodBegan()
          Get the time at which the current Access period began (timestamp, UTC)
 int getAccessPeriodRemaining()
          Get the number of remaining accesses allowed in this current Access Period
 String getAccessPeriodStarts()
          Get the time at which the next Access period begins (timestamp, UTC)
 int getAccessPerPeriod()
          Get the number of accesses allowed per Access Period.
 int getAccessThisPeriod()
          Get the number (count) of accesses in this current Access Period
 String getAPIVersion()
          Get the data feed (server) version.
 java.util.HashMap getAvailableIntervals(boolean flush_cache)
          Load a list of all available data Intervals.
 java.util.HashMap getAvailableSymbols(boolean flush_cache)
          Load a list of all available data Symbols.
 java.util.HashMap getConversion(String convert_from, String convert_to, float convert_value)
          Perform a currency conversion.
 String getCopyright()
          Get copyright information.
 java.util.ArrayList getData()
          Perform a data retrieval.
 String getErrorCode()
          Get Error Code
 String getErrorMessage()
          Get Error Message
 int getInterval()
          Get the data interval used when retrieving data (in seconds)
 String getLicense()
          Get license info (short).
 String getLicenseInfo()
          Get license information (long).
 int getNumQuotes()
          Get the number of quotes contained in the last data retrieval
 int getPeriods()
          Get the number of historic data points to retrive in set Interval.
 String getPrice()
          Get the market price to retrieve when loading data.
 String getRedistribution()
          Get terms of distribution.
 String getStatus()
          Get the status of the last data retrieval function.
 String getSymbol()
          Get the symbol(s) to retrieve when loading data.
 String getWebsite()
          Get the service website URL.
 String setAccessKey(String access_key)
          Sets the Access key to use for all data operations.
 int setInterval(int interval)
          Set the data interval used when retrieving data (in seconds).
 int setPeriods(int periods)
          Set the number of historic data points to retrive in set Interval.
 String setPrice(String price)
          Set the market price to retrieve when loading data.
 String setSymbol(String symbol)
          Set the symbol(s) to retrieve data for.

Constructor Detail

ForexFeed

public ForexFeed(String access_key)
Parameters:
access_key - Your data access key

ForexFeed

public ForexFeed(String access_key,
                 String symbol)
Parameters:
access_key - Your data access key
symbol - Set the symbols to retrieve for

ForexFeed

public ForexFeed(String access_key,
                 String symbol,
                 int interval)
Parameters:
access_key - Your data access key
symbol - Set the symbols to retrieve for
interval - The data interval used when retrieving data (in seconds)

ForexFeed

public ForexFeed(String access_key,
                 String symbol,
                 int interval,
                 int periods)
Parameters:
access_key - Your data access key
symbol - Set the symbols to retrieve for
interval - The data interval used when retrieving data (in seconds)
periods - The number of historic data points to retrive in set interval

ForexFeed

public ForexFeed(String access_key,
                 String symbol,
                 int interval,
                 int periods,
                 String price)
Parameters:
access_key - Your data access key
symbol - Set the symbols to retrieve for
interval - The data interval used when retrieving data (in seconds)
periods - The number of historic data points to retrive in set interval
price - The market price to retrieve
Method Detail

getAccessKey

public String getAccessKey()
Gets the Access key being used for all data operations.

Returns:
access_key Your data access key

setAccessKey

public String setAccessKey(String access_key)
Sets the Access key to use for all data operations.

Parameters:
access_key - Your data access key
Returns:
access_key Your data access key

getSymbol

public String getSymbol()
Get the symbol(s) to retrieve when loading data.

Returns:
The symbols to retrieve when loading data
See Also:
setSymbol(String), getData()

setSymbol

public String setSymbol(String symbol)
Set the symbol(s) to retrieve data for.

Parameters:
symbol - Set the symbols to retrieve for
Returns:
The symbols to retrieve when loading data
See Also:
getSymbol(), getData()

getInterval

public int getInterval()
Get the data interval used when retrieving data (in seconds)

Returns:
The data interval used when retrieving data (in seconds)
See Also:
setInterval(int), getData()

setInterval

public int setInterval(int interval)
Set the data interval used when retrieving data (in seconds).

Parameters:
interval - The data interval used when retrieving data (in seconds)
Returns:
interval The data interval used when retrieving data (in seconds)
See Also:
getInterval(), getData()

getPeriods

public int getPeriods()
Get the number of historic data points to retrive in set Interval.

Returns:
The number of historic data points to retrive in set interval
See Also:
setInterval(int), getData()

setPeriods

public int setPeriods(int periods)
Set the number of historic data points to retrive in set Interval.

Parameters:
periods - The number of historic data points to retrive in set interval
Returns:
The number of historic data points to retrive in set interval
See Also:
setInterval(int), getPeriods(), getData()

getPrice

public String getPrice()
Get the market price to retrieve when loading data.

Returns:
price
See Also:
setPrice(String), getData()

setPrice

public String setPrice(String price)
Set the market price to retrieve when loading data.

Valid options when interval is equal to 1 (ie: tick data);
one of: "mid", "bid,ask"

Valid options when interval is greater than 1 (ie: OHLC data);
one of: "mid", "bid", or "ask"

Parameters:
price - The market price to retrieve.
Returns:
The market price to retrieve.
See Also:
setInterval(int), getPrice(), getData()

getNumQuotes

public int getNumQuotes()
Get the number of quotes contained in the last data retrieval

Returns:
The number of quotes contained in the last data update
See Also:
getData()

getStatus

public String getStatus()
Get the status of the last data retrieval function. Possible values are OK or Error

Returns:
The status of latest data retrieval
See Also:
getData(), getErrorCode(), getErrorMessage()

getErrorCode

public String getErrorCode()
Get Error Code

Returns:
If the last request for data resulted in an Error response, this will contain the error code.
See Also:
getData(), getStatus(), getErrorMessage()

getErrorMessage

public String getErrorMessage()
Get Error Message

Returns:
If the last request for data resulted in an Error response, this will contain the error message.
See Also:
getData(), getStatus(), getErrorCode()

getAPIVersion

public String getAPIVersion()
Get the data feed (server) version.

Returns:
The data feed version

getCopyright

public String getCopyright()
Get copyright information.

Returns:
copyright

getWebsite

public String getWebsite()
Get the service website URL.

Returns:
service website

getRedistribution

public String getRedistribution()
Get terms of distribution.

Returns:
redistribution

getLicense

public String getLicense()
Get license info (short).

Returns:
licence

getLicenseInfo

public String getLicenseInfo()
Get license information (long).

Returns:
licence info

getAccessPeriod

public String getAccessPeriod()
Get the length of the access period, usually a value of day for a 24 hour cycle.

Returns:
The access period duration.
See Also:
getAccessPerPeriod()

getAccessPerPeriod

public int getAccessPerPeriod()
Get the number of accesses allowed per Access Period.

Returns:
The number of hits allowed per period.
See Also:
getAccessPeriod()

getAccessThisPeriod

public int getAccessThisPeriod()
Get the number (count) of accesses in this current Access Period

Returns:
The number of hits in the current period.
See Also:
getAccessPeriod(), getAccessPerPeriod()

getAccessPeriodRemaining

public int getAccessPeriodRemaining()
Get the number of remaining accesses allowed in this current Access Period

Returns:
The number of remaining accesses allowed in this period
See Also:
getAccessPeriod(), getAccessPerPeriod()

getAccessPeriodBegan

public String getAccessPeriodBegan()
Get the time at which the current Access period began (timestamp, UTC)

Returns:
The time at which the current Access period began.

getAccessPeriodStarts

public String getAccessPeriodStarts()
Get the time at which the next Access period begins (timestamp, UTC)

Returns:
The time at which the next Access period begins.

getAvailableSymbols

public java.util.HashMap getAvailableSymbols(boolean flush_cache)
Load a list of all available data Symbols.

This methods maintains a per-instance cache, which can be cleared by calling with the @param flush_cache set to true.

The return value is a Hash of Hashes containing a list available Symbols and thier respective information, keyed by SYMBOL.

The returning sub-Hash contains the following keys:
symbol - The 6 char ISO symbol
title - The human readable short title of the symbol
decimals - The decimal precision (ie: the number of significant digits after the the decimal point)
base_symbol - The 3 char ISO symbol of the base currency
base_title - The descriptive title of the base currency
quote_symbol - The 3 char ISO symbol of the quote currency
quote_title - The descriptive title of the quote currency

Example returned data structure:
   Hash (
    "EURUSD" => Hash (
      "symbol" = "EURUSD",
      "title" = "EUR/USD",
      "decimals" = "5",
      "base_symbol" = "EUR",
      "base_title" = "Euro Member Countries Euro",
      "quote_symbol" = "USD",
      "quote_title" = "United States of America Dollars",
    ),
    "USDCHF" => Hash (
      "symbol" = "USDCHF",
      "title" = "USD/CHF",
      "decimals" = "4",
      "base_symbol" = "USD",
      "base_title" = "United States of America Dollars",
      "quote_symbol" = "CHF",
      "quote_title" = "Switzerland Francs",
    ),

   ...
   )
  

Parameters:
flush_cache - Flushes the (in memory) cache and load fresh list from service.
Returns:
A Hash of Hashes. See the example script.

getAvailableIntervals

public java.util.HashMap getAvailableIntervals(boolean flush_cache)
Load a list of all available data Intervals.

This methods maintains a per-instance cache, which can be cleared by calling with the @param flush_cache set to true.

The return value is a Hash of Hashes containing a list available data Intervals (in seconds) and thier Titles (human readable) keyed to their respective Interval.

The returning sub-Hash contains the following keys:
title - A human readable title of the interval
interval - The length of the interval (in seconds)

Example returned data structure:
   Hash (
    "60" => Hash (
      "title" = "1 Minute",
      "interval" = "60",
    ),
    "3660" => Hash (
      "title" = "1 Hour",
      "interval" = "3660",
    ),

   ...
   )
  

Parameters:
flush_cache - Flushes the (in memory) cache and load fresh list from service.
Returns:
A Hash of Hashes. See the example script.

getConversion

public java.util.HashMap getConversion(String convert_from,
                                       String convert_to,
                                       float convert_value)
Perform a currency conversion.

Each conversion is performed "Live" using the latest market prices.

For example to determine the value of 1 Euro Dollar in US Dollars you could call like so:
HashMap converted = fxObj.getConversion("EUR","USD", 1.00);

The returning Hash contains the following keys:
symbol - 6 char ISO symbol (ie: EURUSD)
title - The title of the symbol (eg: EUR/USD)
convert_from - The 3 char ISO symbol of the base currency (eg: EUR)
convert_to - The 3 char ISO symbol of the to currency (eg: USD)
convert_value - The value in base currency
conversion_rate - The rate at which the conversion was performed (eg: current market price)
conversion_value - The converted value in destination currency

At this time only natural crosses are supported for direct conversion.

Parameters:
convert_from - The 3 character ISO code to convert From
convert_to - The 3 character ISO code to convert To
convert_value - The Value to convert
Returns:
The Value of From in To.

getData

public java.util.ArrayList getData()
Perform a data retrieval.

Each call to getData loads data from the feed using the parameters defined in the various setX() methods.

The return value is a Array of Hashes containing a the retrieved market quotes.

If the interval is set to 1 (for tick data) and price is set to mid then the returned sub-Hash contains the following keys:
symbol - The 6 char ISO symbol
title - The human readable short title of the symbol
time - The timestamp (standard UNIX time / epoch seconds)
price - The current mid-market price (the mid point between Bid and Ask)

If the interval is set to 1 (for tick data) and price is set to bid,ask then the returned sub-Hash contains the following keys:
symbol - The 6 char ISO symbol
title - The human readable short title of the symbol
time - The timestamp (standard UNIX time / epoch seconds)
bid - The current market Bid (sell) price
ask - The current market Ask (buy) price

If the interval is greater than 1 (for Open, High, Low, Close data) then the returned sub-Hash contains the following keys:
symbol - The 6 char ISO symbol
title - The human readable short title of the symbol
time - The timestamp (standard UNIX time / epoch seconds). For OHLC data this value represents the time at which the given quote interval began (as an example: hourly OHLC data intervals begins every hour on the hour)
open - The Opening price of the given interval, which started at time
high - The Highest price of the given interval, which started at time
low - The Lowest price of the given interval, which started at time
close - The Closing price of the given interval, which started at time

Example data structure returned for OHLC data:
   Array (
    0 => Hash (
      "symbol" = "EURUSD",
      "title" = "EUR/USD",
      "time" = "1100188800",
      "open" = "1.28955",
      "high" = "1.28965",
      "low" = "1.28945",
      "close" = "1.28965",
    ),
    1 => Hash (
      "symbol" = "USDCHF",
      "title" = "USD/CHF",
      "time" = "1100188800",
      "open" = "1.17730",
      "high" = "1.17730",
      "low" = "1.17710",
      "close" = "1.17710",
    ),

   ...
   )
  

Returns:
An Array of Hashes containing quotes.
See Also:
setAccessKey(String), setInterval(int), setPeriods(int), setPrice(String), setSymbol(String)