---
title: "Requesting Data"
description: "Request Forex data in your algorithm to receive a feed of exchange rates in the OnData method."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/forex/requesting-data
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/forex/requesting-data.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/03%20Securities/99%20Asset%20Classes/05%20Forex/01%20Requesting%20Data
modified: 2026-10-28
index: https://www.quantconnect.com/llms.txt
---

# Requesting Data

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Securities > [Asset Classes](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes.md) > [Forex](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/forex.md) > Requesting Data

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Request Forex data in your algorithm to receive a feed of exchange rates in the `on_data` method. For more information about the specific dataset we use for backtests, see the [FOREX dataset listing](https://www.quantconnect.com/datasets/oanda-forex). To trade Forex live, you can use the [QuantConnect data provider](https://www.quantconnect.com/docs/v2/cloud-platform/datasets/quantconnect/forex.md).

## Create Subscriptions

To create a Forex pair subscription, in the `initialize` method, call the `add_forex` method. The `add_forex` method returns a `Forex` object, which contains a `symbol` property. Save a reference to the `symbol` so you can use it in `on_data` to access the security data in the `Slice`.

```python
self._symbol = self.add_forex("EURUSD").symbol
```

To view the supported Forex pairs, see [Supported Assets](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/forex-data.md#09-Supported-Assets).

## Resolutions

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

| Resolution | TradeBar | QuoteBar | Trade Tick | Quote Tick |
| --- | --- | --- | --- | --- |
| `TICK` | Not supported | Not supported | Not supported | Supported✓ |
| `SECOND` | Not supported | Supported✓ | Not supported | Not supported |
| `MINUTE` | Not supported | Supported✓ | Not supported | Not supported |
| `HOUR` | Not supported | Supported✓ | Not supported | Not supported |
| `DAILY` | Not supported | Supported✓ | Not supported | Not supported |

The default resolution for Forex subscriptions is `Resolution.MINUTE`. To change the resolution, pass a `resolution` argument to the `add_forex` method.

```python
self._symbol = self.add_forex("EURUSD", Resolution.DAILY).symbol
```

To create custom resolution periods, see [Consolidating Data](https://www.quantconnect.com/docs/v2/writing-algorithms/consolidating-data/getting-started.md).

## Supported Markets

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

```python
self._symbol = self.add_forex("EURUSD", market=Market.OANDA).symbol
```

The [brokerage models](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/brokerages/key-concepts.md) have a default market for each asset class. If you set a brokerage model, you may not need to specify the market to use.

## Fill Forward

Fill forward means if there is no data point for the current [slice](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md), LEAN uses the previous data point. Fill forward is the default data setting. If you disable fill forward, you may get [stale fills](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/trade-fills/key-concepts.md#06-Stale-Fills) or you may see trade volume as zero.

To disable fill forward for a security, set the `fill_forward` argument to false when you create the security subscription.

```python
self._symbol = self.add_forex("EURUSD", fill_forward=False).symbol
```

## 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 `add_forex` method.

```python
self._symbol = self.add_forex("EURUSD", leverage=35).symbol
```

## Data Normalization

The data normalization mode doesn't affect the data that LEAN passes to `on_data` or the data from [history request](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md). If you change the data normalization mode, it won't change the outcome.

## Properties

The `add_forex` method returns a `Forex` object, which have the following properties:

*Members of `QuantConnect.Securities.Forex.Forex` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.Securities.Forex.Forex&language=python*

## Examples

The following examples demonstrate some common practices for requesting Forex data.

### Example 1: Add All Forex Pairs

The following algorithm adds all the Forex pairs that trade on the [OANDA exchange](https://www.quantconnect.com/datasets/oanda-forex) . To get all of the pairs from the [Symbol Properties Database](https://github.com/QuantConnect/Lean/blob/master/Data/symbol-properties/symbol-properties-database.csv) , call the `symbol_properties_database.get_symbol_properties_list` method. Adding all of the pairs is particularly useful for spotting arbitrage opportunities among the pairs.

```python
class ForexExampleAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self._forex_pairs = [
            # Add all of the pairs. You don't need to specify the market because the Symbol object already does.
            self.add_forex(x.key.symbol, Resolution.DAILY)
            # Get all of the OANDA Forex pairs from the Symbol Properties Database.
            for x in self.symbol_properties_database.get_symbol_properties_list(Market.OANDA, SecurityType.FOREX)
        ]
```
