Data Library

Forex

Introduction

QuantConnect supports Forex trading through two popular brokerages; OANDA and FXCM. As most brokerages offer different asset pricing we have prepared and hosted separate datasets from both brokerages we support.

In total QuantConnect hosts 13 currency pairs from Apr 2007 to present provided by FXCM, and 71 currency pairs from Apr 2004 to now provided by OANDA. These currencies are provided as quote data in tick, second, minute, hour and daily resolutions.

To subscribe to FOREX data; use the AddForex() method with the currency pair you'd like information about:

// Complete Add Forex API - Including Default Parameters:
AddForex(string pair,
         Resolution resolution = Resolution.Minute,
         string market = null,
         bool fillDataForward = true,
         decimal leverage = 0m)
# Complete Add Forex API - Including Default Parameters:
self.AddForex(string pair,
    Resolution resolution = Resolution.Minute,
    string market = null,
    bool fillDataForward = true,
    decimal leverage = 0m)

When requesting Forex data you should set your data provider via the market parameter. Forex has two supported market values: FXCM and Oanda.

AddForex("EURUSD", Resolution.Minute, Market.Oanda);
AddForex("EURUSD", Resolution.Minute, Market.FXCM);
self.AddForex("EURUSD", Resolution.Minute, Market.Oanda)
self.AddForex("EURUSD", Resolution.Minute, Market.FXCM)

Quotes can be accessed in the Slice object in OnData event handler:

var bar = data["EURUSD"];
bar = data["EURUSD"]

OANDA Brokerage Forex Data

QuantConnect provides 71 OANDA Brokerage currency pairs for backtesting and trading.

OANDA data is in GMT timezone. Although many popular charting websites convert this to EST for display QuantConnect has elected to leave it in GMT and not manipulate the data. When comparing the data to external references make sure to account for the different time zones.

Data Properties
Data ProviderOANDA
Start Date Mixed Dates: Earliest starts May 30th, 2004
Symbol Universe 71 Currency Pairs ( More Information)

To use OANDA Brokerage FX products in QuantConnect you must specify the QuantConnect symbol not the OANDA one. Data is automatically passed into your algorithm on request. Requested data must be added in the Initialize() method.

// Access data via dedicated event handlers:
public void OnData(TradeBars data) {
    data["EURUSD"].Close;
}
// Access data via grouped time slice method handlers:
public override void OnData(Slice data) {
    data.Bars["EURUSD"].Close;
}
# Access tradebar(midpoints) or quote data (real) via grouped time slice method handlers:
def OnData(self, data):
    data.Bars["EURUSD"].Close
    data.QuoteBars["EURUSD"].Close

FXCM Brokerage Forex Data

QuantConnect provides 39 currency pairs from FXCM for backtesting and live trading; starting as early as April 2007. FXCM currencies have a lower spread than traditional market-makers as FXCM fills trades directly from a number of liquidity providers and offer low competitive spreads. FXCM charges a fixed per lot transaction fee rather than a charging spread.

Data Properties
Data ProviderFXCM
Start Date Mixed; Major symbols start April 1st, 2007.
Symbol Universe 39 Currency Pairs Tickers ( See More)

To use FXCM currency pairs in QuantConnect you must specify the QuantConnect symbol not the FXCM one. Data is automatically passed into your algorithm on request. Requested data must be added in the Initialize() method.

// Manual add symbols required in your initialize method:
public override void Initialize() {
    AddForex("EURUSD", Resolution.Minute);
}
// v2.0 Technique: Access data via dedicated event handlers:
public void OnData(TradeBars data) {
    data["EURUSD"].Close;
}
// v3.0 Technique: Access data via grouped time slice method handlers:
public override void OnData(Slice data) {
    data.Bars["EURUSD"].Close;
}
# Manual add symbols required in your initialize method:
def Initialize(self):
    self.AddForex("EURUSD", Resolution.Minute, Market.FXCM)

# Access data via grouped time slice method handlers:
def OnData(self, data):
    data.Bars["EURUSD"].Close

Timezone

OANDA data is in UTC timezone. Although many popular charting websites convert this to EST for display QuantConnect has elected to leave it in UTC and not manipulate the data. When comparing the data to external references make sure to account for the different time zones. While Oanda data is in UTC Time, the exchange is set to its local time, New York Time. So data accessed from this brokerage is timestamped in New York Time. Meanwhile, all FXCM data is set in UTC-05 Time, or Eastern Standard Time (EST).

About the Providers

OANDA uses innovative computer and financial technology to provide Internet-based forex trading and currency information services to everyone, from individuals to large corporations, from portfolio managers to financial institutions. OANDA is a market maker and a trusted source for currency data. It has access to one of the world's largest historical, high frequency, filtered currency databases.

The FXCM group of companies (collectively, the "FXCM Group") is a leading international provider of online foreign exchange (forex) trading, CFD trading, spread betting and related services to retail and institutional customers world-wide. Founded in 1999 and headquarter in New York, NY, FXCM has operating subsidiaries regulated in a number of jurisdictions, including the United Kingdom and Australia. We also maintain offices in Italy, France, Germany, and Greece.

At the heart of FXCM's client offering is No Dealing Desk forex trading. Clients benefit from FXCM's large network of forex liquidity providers enabling FXCM to offer competitive spreads on major currency pairs. Clients have the advantage of mobile trading, one-click order execution and trading from real-time charts. FXCM's U.K. subsidiary, Forex Capital Markets Limited, also offers CFD products with no re-quote trading and allows clients to trade oil, gold, silver and stock indices along with forex on one platform. In addition, FXCM offers educational courses on forex trading and provides access to exclusive tools through FXCM PLUS.

While FXCM has made every effort to ensure the accuracy of the information provided to QuantConnect, FXCM does not guarantee its accuracy, and will not accept liability for any loss or damage that may arise directly or indirectly from the content or your inability to access the website, for any delay in or failure of the transmission or the receipt of any instruction or notifications sent through this website. Nothing on this website shall be considered a solicitation to buy or an offer to sell any product or service to any person in any jurisdiction where such offer, solicitation, purchase or sale would be unlawful under the laws or regulations of such jurisdiction.

Trading forex/CFDs on margin carries a high level of risk and may not be suitable for all investors as you could sustain losses in excess of deposits. Leverage can work against you. Be aware and fully understand all risks associated with the market and trading. Before deciding to trade any products, carefully consider your financial situation and experience level. Seek advice from an independent financial advisor.

You can also see our Tutorials and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?