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

# Euro Yield Curve

[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) > Euro Yield Curve

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

## Introduction

The Euro Area Yield Curve dataset by the European Central Bank (ECB) tracks the yield curve of euro area government bonds. The data covers 6 yield curves at 10 maturities from 3 months to 30 years, starts in September 2004, and is delivered on a daily frequency. This dataset is created by the ECB fitting a Svensson model to the prices of euro area government bonds.

For more information about the Euro Yield Curve dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/ecb-euro-yield-curve).

## 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 Yield Curve dataset:

```python
self.curve = self.add_data(ECBYieldCurve, ECB.YieldCurves.AAA_SPOT, Resolution.DAILY).symbol
self.all_issuers = self.add_data(ECBYieldCurve, ECB.YieldCurves.ALL_ISSUERS_SPOT, Resolution.DAILY).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | September 2004 |
| Asset Coverage | 6 Yield Curves |
| Data Density | Sparse |
| Resolution | Daily* |
| Timezone | Berlin |

* Published every TARGET business day, about 255 days a year.

## Requesting Data

To add Euro Area Yield Curve 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 ECBYieldCurveDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2018, 1, 1)
        self.set_end_date(2021, 3, 31)
        self.set_cash(100000)

        self.equity = self.add_equity("SPY", Resolution.DAILY).symbol

        self.curve = self.add_data(ECBYieldCurve, ECB.YieldCurves.AAA_SPOT, Resolution.DAILY).symbol
        self.all_issuers = self.add_data(ECBYieldCurve, ECB.YieldCurves.ALL_ISSUERS_SPOT, Resolution.DAILY).symbol
```

## Accessing Data

To get the current Euro Area Yield Curve 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.curve):
        data_point = slice[self.curve]
        self.log(f"{self.curve} 10Y rate at {slice.time}: {data_point.ten_year}")
```

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(ECBYieldCurve).items():
        self.log(f"{dataset_symbol} 10Y rate at {slice.time}: {data_point.ten_year}")
```

## Historical Data

To get historical Euro Area Yield Curve 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.curve, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[ECBYieldCurve](self.curve, 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 Yield Curve data, call the `remove_security` method.

```python
self.remove_security(self.curve)
```

## Supported Curves

The following table shows the accessor code you need to add each curve to your algorithm:

| Curve | Ticker | Constant |
| --- | --- | --- |
| `Triple A rated issuers` |  |  |
| Spot rate | AAA_SPOT | `ECB.YieldCurves.AAA_SPOT` |
| Par yield | AAA_PAR | `ECB.YieldCurves.AAA_PAR` |
| Instantaneous forward | AAA_FORWARD | `ECB.YieldCurves.AAA_FORWARD` |
| `All euro area government issuers` |  |  |
| Spot rate | ALL_SPOT | `ECB.YieldCurves.ALL_ISSUERS_SPOT` |
| Par yield | ALL_PAR | `ECB.YieldCurves.ALL_ISSUERS_PAR` |
| Instantaneous forward | ALL_FORWARD | `ECB.YieldCurves.ALL_ISSUERS_FORWARD` |

## Example Applications

The Euro Area Yield Curve dataset enables you to monitor euro area bond yields across maturities in your strategies. Examples include the following strategies:

- Reducing European equity exposure when the yield curve inverts
- Trading the spread between the AAA and all issuers curves as a sovereign stress signal
- Comparing the euro area and US yield curves for cross-market positioning

### Classic Algorithm Example

The following example algorithm buys SPY when the all issuers 10-year spot rate is at most 60 basis points above the AAA rate. Otherwise, it holds cash.

```python
from AlgorithmImports import *

class ECBYieldCurveExampleAlgorithm(QCAlgorithm):

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

        self.equity = self.add_equity("SPY", Resolution.DAILY).symbol

        self.triple_a = self.add_data(ECBYieldCurve, ECB.YieldCurves.AAA_SPOT, Resolution.DAILY).symbol
        self.all_issuers = self.add_data(ECBYieldCurve, ECB.YieldCurves.ALL_ISSUERS_SPOT, Resolution.DAILY).symbol

        history = self.history[ECBYieldCurve](self.triple_a, timedelta(days=365), Resolution.DAILY)
        self.debug(f"Got {len(list(history))} historical curve readings")

        self.triple_a_ten_year = None
        self.all_issuers_ten_year = None

    def on_data(self, slice):
        curves = slice.get(ECBYieldCurve)

        # Keep the latest 10-year rate of each curve.
        if self.triple_a in curves:
            self.triple_a_ten_year = curves[self.triple_a].ten_year
        if self.all_issuers in curves:
            self.all_issuers_ten_year = curves[self.all_issuers].ten_year

        if self.triple_a_ten_year is None or self.all_issuers_ten_year is None:
            return

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

        spread = (self.all_issuers_ten_year - self.triple_a_ten_year) * 100

        if spread > 60:
            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 10-year rate of the AAA spot curve is above its 2-year rate. Otherwise, it emits flat insights.

```python
from AlgorithmImports import *

class ECBYieldCurveFrameworkAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2018, 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(ECBCurveSlopeAlphaModel(self))

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

class ECBCurveSlopeAlphaModel(AlphaModel):
    """Emits insights from the slope of the euro area yield curve."""

    def __init__(self, algorithm):
        self._curve = algorithm.add_data(ECBYieldCurve, ECB.YieldCurves.AAA_SPOT, Resolution.DAILY).symbol

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

        self._slope = None
        self._symbols = []

    def update(self, algorithm, data):
        curves = data.get(ECBYieldCurve)
        if self._curve in curves:
            data_point = curves[self._curve]
            if data_point.ten_year is not None and data_point.two_year is not None:
                self._slope = data_point.ten_year - data_point.two_year

        if self._slope is None:
            return []

        # Emit up insights while the curve slopes upward and flat insights otherwise.
        direction = InsightDirection.UP if self._slope > 0 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 Yield Curve dataset provides `ECBYieldCurve` objects, which have the following attributes:

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