Requesting Data


Request Forex data in your algorithm to receive a feed of exchange rates in the OnData method. For more information about the specific dataset we use for backtests, see the FOREX dataset listing.

Create Subscriptions

To create a Forex pair subscription, in the Initialize method, call the AddForex method. The AddForex method returns a Forex object, which contains a Symbol. Save a reference to the Symbol so you can use it in OnData to access the security data in the Slice.

_symbol = AddForex("EURUSD").Symbol;
self.symbol = self.AddForex("EURUSD").Symbol

To view the supported Forex pairs, see Supported Assets.


The following table shows the available resolutions and data formats for Forex subscriptions:

ResolutionTradeBarQuoteBarTrade TickQuote Tick
Tickgreen check
green check
green check
green check
green check

The default resolution for Forex subscriptions is Resolution.Minute. To change the resolution, pass a resolution argument to the AddForex method.

_symbol = AddForex("EURUSD", Resolution.Daily).Symbol;
self.symbol = self.AddForex("EURUSD", Resolution.Daily).Symbol

To create custom resolution periods, see Consolidating Data.

Supported Markets

The only market available for Forex pairs is Market.Oanda, so you don't need to pass a market argument to the AddForex method.

_symbol = AddForex("EURUSD", market: Market.Oanda).Symbol;
self.symbol = self.AddForex("EURUSD", market=Market.Oanda).Symbol

The brokerage models have a default market for each asset class. If you set a brokerage model, you may not need to specify the market to use.

Margin and Leverage

LEAN models buying power and margin calls to ensure your algorithm stays within the margin requirements. The Oanda brokerage let's you use up to 50x leverage on margin accounts. To change the amount of leverage you can use for a Forex pair, pass a leverage argument to the AddForex method.

_symbol = AddForex("EURUSD", leverage: 35).Symbol;
self.symbol = self.AddForex("EURUSD", leverage=35).Symbol

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: