---
title: "Macro Indicators"
description: "Macro Indicators dataset from Eurostat."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eurostat/macro-indicators
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eurostat/macro-indicators.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/15%20Eurostat/01%20Macro%20Indicators
modified: 2026-11-11
index: https://www.quantconnect.com/llms.txt
---

# Macro Indicators

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Eurostat](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eurostat.md) > Macro Indicators

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

## Introduction

The Macroeconomic Indicators dataset by Eurostat tracks consumer prices, producer prices, industrial production, retail trade, unemployment, and GDP for European economies. The data covers up to 46 European economies, starts in January 1975, and is delivered on a monthly frequency, with GDP delivered quarterly. This dataset is created by processing the statistics Eurostat publishes through its public API. The series are not seasonally adjusted, so they differ from the figures quoted in the press.

For more information about the Macro Indicators dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/eurostat-macro-indicators).

## About the Provider

Eurostat is the statistical office of the European Union, founded in 1953 and based in Luxembourg. It collects data from the national statistics offices and publishes statistics that can be compared across European countries.

## Getting Started

The following snippet demonstrates how to request data from the Macroeconomic Indicators dataset:

```python
self.prices = self.add_data(EurostatConsumerPrices, Eurostat.Economies.EURO_AREA, Resolution.DAILY).symbol
self.production = self.add_data(EurostatIndustrialProduction, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 1975 |
| Asset Coverage | 51 Economies |
| Data Density | Sparse |
| Resolution | Daily* |
| Timezone | Brussels |

* Monthly and quarterly data we fetch daily.

## Requesting Data

To add Macroeconomic Indicators 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 EurostatIndicatorsDataAlgorithm(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.prices = self.add_data(EurostatConsumerPrices, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self.production = self.add_data(EurostatIndustrialProduction, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self.gdp = self.add_data(EurostatGrossDomesticProduct, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
```

## Accessing Data

To get the current Macroeconomic Indicators 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.prices):
        data_point = slice[self.prices]
        self.log(f"{self.prices} HICP at {slice.time}: {data_point.all_items}")
```

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(EurostatIndustrialProduction).items():
        self.log(f"{dataset_symbol} industrial production at {slice.time}: {data_point.total_industry}")
```

## Historical Data

To get historical Macroeconomic Indicators 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.prices, timedelta(days=1825), Resolution.DAILY)

# Dataset objects
history_bars = self.history[EurostatConsumerPrices](self.prices, timedelta(days=1825), 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 Macroeconomic Indicators data, call the `remove_security` method.

```python
self.remove_security(self.prices)
```

## Supported Economies

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

| Economy | Geo code | Constant |
| --- | --- | --- |
| `Aggregates` |  |  |
| Euro area (21 countries) | EA21 | `Eurostat.Economies.EURO_AREA` |
| Euro area (20 countries) | EA20 | `Eurostat.Economies.EURO_AREA_20` |
| Euro area (19 countries) | EA19 | `Eurostat.Economies.EURO_AREA_19` |
| Euro area (12 countries) | EA12 | `Eurostat.Economies.EURO_AREA_12` |
| Euro area, chain linked | EA | `Eurostat.Economies.EURO_AREA_CHAINED` |
| European Union | EU27_2020 | `Eurostat.Economies.EUROPEAN_UNION` |
| European Union, chain linked | EU | `Eurostat.Economies.EUROPEAN_UNION_CHAINED` |
| European Economic Area | EEA | `Eurostat.Economies.EUROPEAN_ECONOMIC_AREA` |
| `Countries` |  |  |
| Albania | AL | `Eurostat.Economies.ALBANIA` |
| Austria | AT | `Eurostat.Economies.AUSTRIA` |
| Belgium | BE | `Eurostat.Economies.BELGIUM` |
| Bosnia and Herzegovina | BA | `Eurostat.Economies.BOSNIA_AND_HERZEGOVINA` |
| Bulgaria | BG | `Eurostat.Economies.BULGARIA` |
| Croatia | HR | `Eurostat.Economies.CROATIA` |
| Cyprus | CY | `Eurostat.Economies.CYPRUS` |
| Czechia | CZ | `Eurostat.Economies.CZECHIA` |
| Denmark | DK | `Eurostat.Economies.DENMARK` |
| Estonia | EE | `Eurostat.Economies.ESTONIA` |
| Finland | FI | `Eurostat.Economies.FINLAND` |
| France | FR | `Eurostat.Economies.FRANCE` |
| Georgia | GE | `Eurostat.Economies.GEORGIA` |
| Germany | DE | `Eurostat.Economies.GERMANY` |
| Greece | EL | `Eurostat.Economies.GREECE` |
| Hungary | HU | `Eurostat.Economies.HUNGARY` |
| Iceland | IS | `Eurostat.Economies.ICELAND` |
| Ireland | IE | `Eurostat.Economies.IRELAND` |
| Italy | IT | `Eurostat.Economies.ITALY` |
| Japan | JP | `Eurostat.Economies.JAPAN` |
| Kosovo | XK | `Eurostat.Economies.KOSOVO` |
| Latvia | LV | `Eurostat.Economies.LATVIA` |
| Lithuania | LT | `Eurostat.Economies.LITHUANIA` |
| Luxembourg | LU | `Eurostat.Economies.LUXEMBOURG` |
| Malta | MT | `Eurostat.Economies.MALTA` |
| Moldova | MD | `Eurostat.Economies.MOLDOVA` |
| Montenegro | ME | `Eurostat.Economies.MONTENEGRO` |
| Netherlands | NL | `Eurostat.Economies.NETHERLANDS` |
| North Macedonia | MK | `Eurostat.Economies.NORTH_MACEDONIA` |
| Norway | NO | `Eurostat.Economies.NORWAY` |
| Poland | PL | `Eurostat.Economies.POLAND` |
| Portugal | PT | `Eurostat.Economies.PORTUGAL` |
| Romania | RO | `Eurostat.Economies.ROMANIA` |
| Serbia | RS | `Eurostat.Economies.SERBIA` |
| Slovakia | SK | `Eurostat.Economies.SLOVAKIA` |
| Slovenia | SI | `Eurostat.Economies.SLOVENIA` |
| Spain | ES | `Eurostat.Economies.SPAIN` |
| Sweden | SE | `Eurostat.Economies.SWEDEN` |
| Switzerland | CH | `Eurostat.Economies.SWITZERLAND` |
| Turkiye | TR | `Eurostat.Economies.TURKIYE` |
| Ukraine | UA | `Eurostat.Economies.UKRAINE` |
| United Kingdom | UK | `Eurostat.Economies.UNITED_KINGDOM` |
| United States | US | `Eurostat.Economies.UNITED_STATES` |

## Example Applications

The Macroeconomic Indicators dataset enables you to follow the European economy in your strategies. Examples include the following strategies:

- Trading euro area rates or the euro around consumer price releases
- Rotating country exposure based on industrial production across economies
- Scaling risk up or down with unemployment and GDP growth

### Classic Algorithm Example

The following example algorithm buys SPY when German industrial production rises. Otherwise, it liquidates the position.

```python
from AlgorithmImports import *

class EurostatIndicatorsExampleAlgorithm(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.prices = self.add_data(EurostatConsumerPrices, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self.production = self.add_data(EurostatIndustrialProduction, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol

        self.previous_production = None

    def on_data(self, slice):
        prices = slice.get(EurostatConsumerPrices)
        if self.prices in prices:
            data_point = prices[self.prices]
            self.debug(f"HICP all items: {data_point.all_items}, core: {data_point.core}, energy: {data_point.energy}")

        production = slice.get(EurostatIndustrialProduction)
        if self.production not in production:
            return

        total_industry = production[self.production].total_industry
        if total_industry is None:
            return

        # Buy SPY when industrial production rises. Otherwise, liquidate.
        if self.previous_production is not None:
            if total_industry > self.previous_production:
                self.set_holdings(self.equity, 1)
            else:
                self.liquidate(self.equity)

        self.previous_production = total_industry
```

### Framework Algorithm Example

The following example algorithm emits up insights for SPY when German industrial production rises and unemployment does not. Otherwise, it emits flat insights.

```python
from AlgorithmImports import *

class EurostatIndicatorsFrameworkAlgorithm(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(EurostatMacroCycleAlphaModel(self))

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

class EurostatMacroCycleAlphaModel(AlphaModel):
    """Emits insights from German industrial production and unemployment."""

    def __init__(self, algorithm):
        self._production = algorithm.add_data(EurostatIndustrialProduction, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self._labour = algorithm.add_data(EurostatLabourMarket, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol

        history = algorithm.history(EurostatIndustrialProduction, self._production, timedelta(days=1825), Resolution.DAILY)
        algorithm.debug(f"Got {len(history)} historical industrial production rows")

        self._previous_production = None
        self._previous_unemployment = None
        self._symbols = []

    def update(self, algorithm, data):
        insights = []

        production = data.get(EurostatIndustrialProduction)
        if self._production not in production:
            return insights

        total_industry = production[self._production].total_industry
        if total_industry is None:
            return insights

        # Read the latest unemployment rate from the security cache.
        labour_point = algorithm.securities[self._labour].cache.get_data(EurostatLabourMarket)
        unemployment = labour_point.unemployment_rate if labour_point else None

        if self._previous_production is not None:
            expanding = total_industry > self._previous_production
            if expanding and unemployment is not None and self._previous_unemployment is not None:
                expanding = unemployment <= self._previous_unemployment

            direction = InsightDirection.UP if expanding else InsightDirection.FLAT
            insights = [Insight.price(symbol, timedelta(days=30), direction) for symbol in self._symbols]

        self._previous_production = total_industry
        if unemployment is not None:
            self._previous_unemployment = unemployment

        return insights

    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 Macroeconomic Indicators dataset provides `EurostatConsumerPrices`, `EurostatIndustrialProduction`, `EurostatProducerPrices`, `EurostatRetailTrade`, `EurostatLabourMarket` and `EurostatGrossDomesticProduct` objects.

### EurostatConsumerPrices

`EurostatConsumerPrices` objects have the following attributes:

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

### EurostatIndustrialProduction

`EurostatIndustrialProduction` objects have the following attributes:

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

### EurostatProducerPrices

`EurostatProducerPrices` objects have the following attributes:

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

### EurostatRetailTrade

`EurostatRetailTrade` objects have the following attributes:

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

### EurostatLabourMarket

`EurostatLabourMarket` objects have the following attributes:

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

### EurostatGrossDomesticProduct

`EurostatGrossDomesticProduct` objects have the following attributes:

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