---
title: "Policy Rates"
description: "Policy Rates dataset from European Central Bank."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/european-central-bank/policy-rates
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/european-central-bank/policy-rates.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/14%20European%20Central%20Bank/02%20Policy%20Rates
modified: 2026-11-25
index: https://www.quantconnect.com/llms.txt
---

# Policy Rates

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [European Central Bank](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/european-central-bank.md) > Policy Rates

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

## Introduction

The Euro Area Policy Rates dataset by the European Central Bank (ECB) tracks the three key ECB interest rates and the euro short-term rate. The data covers the euro area, starts in January 1999, and is delivered on a daily frequency. This dataset is created by processing the rates the ECB publishes on its Data Portal. The euro short-term rate starts in October 2019.

For more information about the Policy Rates dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/ecb-policy-rates).

## About the Provider

The European Central Bank is the central bank of the euro area, established in 1998 and based in Frankfurt. Its main task is to keep prices stable in the countries that use the euro, and it sets the interest rates for the euro area. It also publishes statistics on the euro area economy and its financial markets.

## Getting Started

The following snippet demonstrates how to request data from the Euro Area Policy Rates dataset:

```python
self.rates = self.add_data(ECBPolicyRates, ECB.PolicyRates.EURO_AREA, Resolution.DAILY).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 1999 |
| Asset Coverage | 1 Euro Area Series |
| Data Density | Regular |
| Resolution | Daily* |
| Timezone | Berlin |

* One row per weekday, including TARGET holidays.

## Requesting Data

To add Euro Area Policy Rates data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

```python
class ECBPolicyRatesExampleAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2020, 1, 1)
        self.set_end_date(2021, 1, 1)
        self._rates = self.add_data(ECBPolicyRates, ECB.PolicyRates.EURO_AREA).symbol
```

## Accessing Data

To get the current Euro Area Policy Rates data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) with the dataset `Symbol`. `Slice` objects deliver unique events to your algorithm as they happen, but the `Slice` may not contain data for your dataset at every time step. To avoid issues, check if the `Slice` contains the data you want before you index it.

```python
def on_data(self, slice: Slice) -> None:
    if slice.contains_key(self._rates):
        data_point = slice[self._rates]
        self.log(f"{self._rates} deposit facility rate at {slice.time}: {data_point.deposit_facility_rate}")
```

To iterate through all of the dataset objects in the current `Slice`, call the `get` method.

```python
def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.get(ECBPolicyRates).items():
        self.log(f"{dataset_symbol} deposit facility rate at {slice.time}: {data_point.deposit_facility_rate}")
```

## Historical Data

To get historical Euro Area Policy Rates data, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# DataFrame
history_df = self.history(self._rates, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[ECBPolicyRates](self._rates, 100, Resolution.DAILY)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Remove Subscriptions

To remove your subscription to Euro Area Policy Rates data, call the `remove_security` method.

```python
self.remove_security(self._rates)
```

## Supported Rates

The following table shows the rates in the Euro Area Policy Rates dataset:

| Rate | Property | Coverage |
| --- | --- | --- |
| Main refinancing operations | `main_refinancing_rate` | January 1999 onward |
| Deposit facility | `deposit_facility_rate` | January 1999 onward |
| Marginal lending facility | `marginal_lending_rate` | January 1999 onward |
| Euro short-term rate | `euro_short_term_rate` | October 2019 onward |

## Example Applications

The Euro Area Policy Rates dataset enables you to follow ECB monetary policy in your strategies. Examples include the following strategies:

- Trading the gap between the euro short-term rate and the deposit facility rate
- Using the euro funding cost in carry and financing calculations
- Comparing ECB and Federal Reserve rates for currency positioning

### Classic Algorithm Example

The following example algorithm buys SPY when the euro short-term rate is at least five basis points below the deposit facility rate. Otherwise, it holds cash.

```python
from AlgorithmImports import *

class ECBPolicyRatesAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2021, 3, 31)
        self.set_cash(100000)

        self.equity = self.add_equity("SPY", Resolution.DAILY).symbol
        self.rates = self.add_data(ECBPolicyRates, ECB.PolicyRates.EURO_AREA, Resolution.DAILY).symbol

        self.spread = None

    def on_data(self, slice: Slice) -> None:
        rates = slice.get(ECBPolicyRates)
        if self.rates in rates:
            point = rates[self.rates]

            if point.euro_short_term_rate is not None and point.deposit_facility_rate is not None:
                self.log(f"{point.end_time} corridor: deposit {point.deposit_facility_rate}, "
                         f"main {point.main_refinancing_rate}, lending {point.marginal_lending_rate}, "
                         f"overnight {point.euro_short_term_rate}")

                # Measure how far the overnight rate trades below the deposit facility rate.
                self.spread = point.euro_short_term_rate - point.deposit_facility_rate

        if self.spread is None:
            return

        # Wait for the SPY bar before trading.
        if self.equity not in slice.bars:
            return

        if self.spread > -0.05:
            if self.portfolio[self.equity].invested:
                self.liquidate(self.equity)
        elif not self.portfolio[self.equity].invested:
            self.set_holdings(self.equity, 1)
```

### Framework Algorithm Example

The following example algorithm emits up insights for SPY when the euro short-term rate is at least five basis points below the deposit facility rate. Otherwise, it emits flat insights.

```python
from AlgorithmImports import *

class ECBPolicyRatesFrameworkAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2021, 3, 31)
        self.set_cash(100000)

        self.universe_settings.resolution = Resolution.DAILY

        symbols = [Symbol.create("SPY", SecurityType.EQUITY, Market.USA)]
        self.set_universe_selection(ManualUniverseSelectionModel(symbols))

        self.add_alpha(ECBCorridorAlphaModel(self))

        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
        self.set_execution(ImmediateExecutionModel())

class ECBCorridorAlphaModel(AlphaModel):
    """Emits insights from where the overnight rate sits against the corridor floor."""

    def __init__(self, algorithm):
        self._rates = algorithm.add_data(ECBPolicyRates, ECB.PolicyRates.EURO_AREA, Resolution.DAILY).symbol

        history = algorithm.history[ECBPolicyRates](self._rates, timedelta(days=365), Resolution.DAILY)
        algorithm.debug(f"Got {len(list(history))} historical rate readings")

        self._spread = None
        self._symbols = []

    def update(self, algorithm, data):
        rates = data.get(ECBPolicyRates)
        if self._rates in rates:
            data_point = rates[self._rates]
            if data_point.euro_short_term_rate is not None and data_point.deposit_facility_rate is not None:
                # Measure how far the overnight rate trades below the deposit facility rate.
                self._spread = data_point.euro_short_term_rate - data_point.deposit_facility_rate

        if self._spread is None:
            return []

        # Emit up insights while the gap is wide and flat insights once it closes.
        direction = InsightDirection.UP if self._spread <= -0.05 else InsightDirection.FLAT

        # Emit insights only for the securities that have a bar in this slice.
        return [Insight.price(symbol, timedelta(days=30), direction)
                for symbol in self._symbols if symbol in data.bars]

    def on_securities_changed(self, algorithm, changes):
        for security in changes.added_securities:
            self._symbols.append(security.symbol)

        for security in changes.removed_securities:
            if security.symbol in self._symbols:
                self._symbols.remove(security.symbol)
```

## Data Point Attributes

The Euro Area Policy Rates dataset provides `ECBPolicyRates` objects, which have the following attributes:

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