Skip to content

1Forge/java-forex-quotes

Repository files navigation

Maven Central

java-forex-quotes

java-forex-quotes is a Java library for fetching realtime forex quotes. Any contributions or issues opened are greatly appreciated. Please see the example here.

Table of Contents

Requirements

Known Issues

Please see the list of known issues here: Issues

Installation

The .jar can be found here

Usage

Initialize the client

import com._1forge.java;

//Initialize the client
ForexDataClient client = new ForexDataClient("YOUR_API_KEY");

Get the list of available symbols:

try
{
    Symbol[] symbols = client.getSymbols();

    for (Symbol s : symbols)
    {
        System.out.println(s);
    }
}
catch(Exception e)
{
    System.out.println(e.toString());
}

Get quotes for specified symbols:

try
{
    String[] tickers = {"EUR/USD", "GBP/JPY", "BTC/USD"};
    Symbol[] symbols = Symbol.fromStringArray(tickers);
    Quote[] quotes = client.getQuotes(symbols);

    for (Quote q : quotes)
    {
        System.out.println(q);
    }
}
catch(Exception e)
{
    System.out.println(e.toString());
}

Convert from one currency to another:

try
{
    ConversionResult conversion = client.convert("EUR", "USD", 100d);
    System.out.println(conversion);
}
catch(Exception e)
{
    System.out.println(e.toString());
}

Check if the market is open:

try
{
     MarketStatus marketStatus = client.getMarketStatus();
     if (marketStatus.marketIsOpen)
     {
         System.out.println("The market is open.");
     }
     else {
         System.out.println("The market is closed.");
     }
}
catch(Exception e)
{
    System.out.println(e.toString());
}

Quota used

try
{
    Quota quota = client.getQuota();
    System.out.println(quota);
}
catch(Exception e)
{
    System.out.println(e.toString());
}

Support and Contact

Please contact me at contact@1forge.com if you have any questions or requests.

License and Terms

This library is provided without warranty under the MIT license.