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.
- An API key which you can obtain for free at http://1forge.com/forex-data-api
Please see the list of known issues here: Issues
The .jar can be found here
import com._1forge.java;
//Initialize the client
ForexDataClient client = new ForexDataClient("YOUR_API_KEY");
try
{
Symbol[] symbols = client.getSymbols();
for (Symbol s : symbols)
{
System.out.println(s);
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
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());
}
try
{
ConversionResult conversion = client.convert("EUR", "USD", 100d);
System.out.println(conversion);
}
catch(Exception e)
{
System.out.println(e.toString());
}
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());
}
try
{
Quota quota = client.getQuota();
System.out.println(quota);
}
catch(Exception e)
{
System.out.println(e.toString());
}
Please contact me at contact@1forge.com if you have any questions or requests.
This library is provided without warranty under the MIT license.