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 page serves as a general reference for all APIs. For language-specific examples please see the examples provided with each API package.

Class ForexFeed



  • public class ForexFeed
    extends Object
    • Constructor Summary

      Constructors 
      Constructor and Description
      ForexFeed(String app_id) 
      ForexFeed(String app_id, String symbol) 
      ForexFeed(String app_id, String symbol, int interval) 
      ForexFeed(String app_id, String symbol, int interval, int periods) 
      ForexFeed(String app_id, String symbol, int interval, int periods, String price) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      String getAccessKey()
      Deprecated.

      Developers should use the getAppID function instead of getAccessKey.
      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
      int getAgree()
      Get the Agree To Terms Flag.
      String getAPIVersion()
      Get the data feed (server) version.
      String getAppID()
      Gets the AppID currently being used for all data operations.
      HashMap getAvailableIntervals(boolean flush_cache)
      Deprecated.

      Developers should use getIntervals instead.
      HashMap getAvailableSymbols(boolean flush_cache)
      Deprecated.

      Developers should use the getSymbols function instead of getAvailableSymbols.
      HashMap getConversion(String convert_from, String convert_to, float convert_value)
      Perform a currency conversion.
      String getCopyright()
      Get copyright information.
      ArrayList getData()
      Perform a data retrieval.
      ArrayList getDataCached()
      Get the Currently cached Dataset.
      String getErrorCode()
      Get Error Code
      String getErrorMessage()
      Get Error Message
      String getFields()
      Get the Data Fields to include when loading data.
      String getHostname() 
      int getInterval()
      Get the data interval used when retrieving data (in seconds).
      HashMap getIntervals(boolean flush_cache)
      Load a list of all available data Intervals.
      String getLicense()
      Get license info (short).
      String getLicenseInfo()
      Get license information (long).
      int getNoStats()
      Get the NoStats Flag.
      int getNumQuotes()
      Get the number of quotes contained in the last data retrieval
      int getPeriods()
      Get the number of historic data points to retrieve in set Interval.
      int getPort() 
      String getPrice()
      Get the market price to retrieve when loading data.
      String getRedistribution()
      Get terms of distribution.
      int getStartTime() 
      String getStatus()
      Get the status of the last data retrieval function.
      String getSymbol()
      Get the symbol(s) to retrieve when loading data.
      HashMap getSymbols(boolean flush_cache)
      Load a list of all available data Symbols.
      int getTimeout() 
      String getToken(int timeout)
      Retrieve a new Access Token.
      String getWebsite()
      Get the service website URL.
      String setAccessKey(String app_id)
      Deprecated.

      Developers should use the setAppID function instead of setAccessKey.
      int setAgree(int agree)
      Set the Agree To Terms Flag.
      String setAppID(String app_id)
      Sets the AppID to use for all data operations.
      String setFields(String fields)
      Set the Data Fields to include when loading data.
      String setHostname(String host) 
      int setInterval(int interval)
      Set the data interval used when retrieving data (in seconds).
      int setNoStats(int no_stats)
      Set the NoStats Flag.
      int setPeriods(int periods)
      Set the number of historic data points to retrieve in set Interval.
      int setPort(int port) 
      String setPrice(String price)
      Set the market price to retrieve when loading data.
      int setStartTime(int time)
      Set the Starting Time for Loading OHLC Data.
      String setSymbol(String symbol)
      Set the symbol(s) to retrieve data for.
      int setTimeout(int timeout) 
    • Constructor Detail

      • ForexFeed

        public ForexFeed(String app_id)
        Parameters:
        app_id - Your unique App ID
      • ForexFeed

        public ForexFeed(String app_id,
                         String symbol)
        Parameters:
        app_id - Your unique App ID
        symbol - Set the symbols to retrieve data for
      • ForexFeed

        public ForexFeed(String app_id,
                         String symbol,
                         int interval)
        Parameters:
        app_id - Your unique App ID
        symbol - Set the symbols to retrieve for
        interval - The data interval used when retrieving data (in seconds)
      • ForexFeed

        public ForexFeed(String app_id,
                         String symbol,
                         int interval,
                         int periods)
        Parameters:
        app_id - Your unique App ID
        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 retrieve in set interval
      • ForexFeed

        public ForexFeed(String app_id,
                         String symbol,
                         int interval,
                         int periods,
                         String price)
        Parameters:
        app_id - Your unique App ID
        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 retrieve in set interval
        price - The market price to retrieve
    • Method Detail

      • getHostname

        public String getHostname()
      • setHostname

        public String setHostname(String host)
      • getPort

        public int getPort()
      • setPort

        public int setPort(int port)
      • getTimeout

        public int getTimeout()
      • setTimeout

        public int setTimeout(int timeout)
      • getStartTime

        public int getStartTime()
        Returns:
        - the Start Time
      • setStartTime

        public int setStartTime(int time)
        Set the Starting Time for Loading OHLC Data.
        Parameters:
        time - - The Starting Time in Epoch Seconds (ie: seconds since Jan 1, 1970)
        Returns:
        - the Start Time
      • getAppID

        public String getAppID()
        Gets the AppID currently being used for all data operations.
        Returns:
        app_id Your unique App ID registered at ForexFeed
      • getAccessKey

        public String getAccessKey()
        Deprecated.

        Developers should use the getAppID function instead of getAccessKey.
        Returns:
        app_id
        See Also:
        getAppID()
      • setAppID

        public String setAppID(String app_id)
        Sets the AppID to use for all data operations.
        Parameters:
        app_id - Your unique App ID
        Returns:
        app_id Your unique App ID
      • setAccessKey

        public String setAccessKey(String app_id)
        Deprecated.

        Developers should use the setAppID function instead of setAccessKey.
        Parameters:
        app_id - Your unique App ID
        Returns:
        app_id
        See Also:
        setAppID(String)
      • 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 symbol(s) 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).

        Currently supported Data Intervals include:
        1 = Tick data (for Bid/Ask or Mid quotes)
        5 = 5 Second data (OHLC)
        10 = 10 Second data (OHLC)
        30 = 30 Second data (OHLC)
        45 = 45 Second data (OHLC)
        60 = 1 Minute data (OHLC)
        300 = 5 Minute data (OHLC)
        600 = 10 Minute data (OHLC)
        900 = 15 Minute data (OHLC)
        1200 = 20 Minute data (OHLC)
        1800 = 30 Minute data (OHLC)
        2700 = 45 Minute data (OHLC)
        3600 = 1 Hour data (OHLC)
        7200 = 2 Hour data (OHLC)
        10800 = 3 Hour data (OHLC)
        14400 = 4 Hour data (OHLC)
        21600 = 6 Hour data (OHLC)
        43200 = 12 Hour data (OHLC)
        86400 = 1 Day/Daily data (OHLC)
        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 retrieve in set Interval.
        Returns:
        The number of historic data points to retrieve in set interval
        See Also:
        setInterval(int), getData()
      • setPeriods

        public int setPeriods(int periods)
        Set the number of historic data points to retrieve in set Interval.
        Parameters:
        periods - The number of historic data points to retrieve in set interval
        Returns:
        The number of historic data points to retrieve 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()
      • getFields

        public String getFields()
        Get the Data Fields to include when loading data.
        Returns:
        fields
        See Also:
        setFields(String), getData()
      • setFields

        public String setFields(String fields)
        Set the Data Fields to include when loading data.

        Valid options when interval is greater than 1 (ie: OHLC data);
        one of: "ohlc", "ohlcv"
        Parameters:
        fields - The data fields to retrieve.
        Returns:
        The data fields to retrieve.
        See Also:
        setInterval(int), getFields(), getData()
      • setAgree

        public int setAgree(int agree)
        Set the Agree To Terms Flag.

        This may be used to suppress the License statement in Server responses.

        Setting agree to a value of 1 signifies your agreement to the terms within, in no way does it alter your license, rights and/or limitations and you agree to be bound by any existing license agreement.

        This may be useful in low-bandwidth conditions, for example. Or simply to conserve some bytes on each request/response.
        Parameters:
        agree - Agree To Terms
        Returns:
        agree
        See Also:
        getAgree()
      • getAgree

        public int getAgree()
        Get the Agree To Terms Flag.
        Returns:
        agree
        See Also:
        setAgree(int)
      • setNoStats

        public int setNoStats(int no_stats)
        Set the NoStats Flag.

        This may be used to suppress the Account Stats in getData() responses by
        setting the NoStats flag to a value of 1
        This may be useful in low-bandwidth conditions, for example. Or simply to conserve some bytes on each request/response.

        Note however that the Account Statistics information (usually available through the various getAccess* functions) will not be available on Data Requests.

        Parameters:
        no_stats - No Stats Flag
        Returns:
        no_stats
        See Also:
        getData()
      • getNoStats

        public int getNoStats()
        Get the NoStats Flag.
        Returns:
        agree
        See Also:
        setNoStats(int)
      • 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:
        license
      • getLicenseInfo

        public String getLicenseInfo()
        Get license information (long).
        Returns:
        license 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 HashMap getAvailableSymbols(boolean flush_cache)
        Deprecated.

        Developers should use the getSymbols function instead of getAvailableSymbols.
        Parameters:
        flush_cache - Flushes the (in memory) cache and load fresh list from service.
        Returns:
        A Hash of Hashes.
        See Also:
        getSymbols(boolean)
      • getSymbols

        public HashMap getSymbols(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 their 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 HashMap getAvailableIntervals(boolean flush_cache)
        Deprecated.

        Developers should use getIntervals instead.
        Parameters:
        flush_cache - Flushes the (in memory) cache and load fresh list from service.
        Returns:
        A Hash of Hashes.
        See Also:
        getIntervals(boolean)
      • getIntervals

        public HashMap getIntervals(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 their 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.
      • getToken

        public String getToken(int timeout)
        Retrieve a new Access Token.

        Parameters:
        timeout - Token Timeout / Lifetime (in seconds)
        Returns:
        A new Access Token
      • getConversion

        public 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.
      • getDataCached

        public ArrayList getDataCached()
        Get the Currently cached Dataset.

        This function returns the currently loaded dataset.
        The currently loaded dataset is a cache containing the results of the latest call to #getData.

        Returns:
        An Array of Hashes containing quotes.
        See Also:
        getData()
      • getData

        public 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:
        setAppID(String), setInterval(int), setPeriods(int), setPrice(String), setSymbol(String)