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

# Surveys

[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) > Surveys

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

## Introduction

The Business and Consumer Surveys dataset by Eurostat tracks the monthly confidence surveys of households and of businesses in industry, construction, retail, and services. The data covers up to 35 European economies, starts in January 1980, and is delivered on a monthly frequency. This dataset is created by processing the European Commission surveys that Eurostat publishes. The series are not seasonally adjusted, so they differ from the figures quoted in the press.

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

## 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 Business and Consumer Surveys dataset:

```python
self.consumer = self.add_data(EurostatConsumerSurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
self.industry = self.add_data(EurostatIndustrySurvey, Eurostat.Economies.EURO_AREA, Resolution.DAILY).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 1980 |
| Asset Coverage | 35 European Economies |
| Data Density | Sparse |
| Resolution | Daily* |
| Timezone | Brussels |

* Monthly data we fetch daily.

## Requesting Data

To add Business and Consumer Surveys 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 EurostatSurveysDataAlgorithm(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.consumer = self.add_data(EurostatConsumerSurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self.industry = self.add_data(EurostatIndustrySurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self.services = self.add_data(EurostatServicesSurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
```

## Accessing Data

To get the current Business and Consumer Surveys 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.consumer):
        data_point = slice[self.consumer]
        self.log(f"{self.consumer} consumer confidence at {slice.time}: {data_point.consumer_confidence}")
```

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

## Historical Data

To get historical Business and Consumer Surveys 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.consumer, timedelta(days=1825), Resolution.DAILY)

# Dataset objects
history_bars = self.history[EurostatConsumerSurvey](self.consumer, 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 Business and Consumer Surveys data, call the `remove_security` method.

```python
self.remove_security(self.consumer)
```

## 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 | EA21 | `Eurostat.Economies.EURO_AREA` |
| Euro area (20 countries) | EA20 | `Eurostat.Economies.EURO_AREA_20` |
| European Union | EU27_2020 | `Eurostat.Economies.EUROPEAN_UNION` |
| `Countries` |  |  |
| Albania | AL | `Eurostat.Economies.ALBANIA` |
| Austria | AT | `Eurostat.Economies.AUSTRIA` |
| Belgium | BE | `Eurostat.Economies.BELGIUM` |
| 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` |
| Germany | DE | `Eurostat.Economies.GERMANY` |
| Greece | EL | `Eurostat.Economies.GREECE` |
| Hungary | HU | `Eurostat.Economies.HUNGARY` |
| Ireland | IE | `Eurostat.Economies.IRELAND` |
| Italy | IT | `Eurostat.Economies.ITALY` |
| Latvia | LV | `Eurostat.Economies.LATVIA` |
| Lithuania | LT | `Eurostat.Economies.LITHUANIA` |
| Luxembourg | LU | `Eurostat.Economies.LUXEMBOURG` |
| Malta | MT | `Eurostat.Economies.MALTA` |
| Montenegro | ME | `Eurostat.Economies.MONTENEGRO` |
| Netherlands | NL | `Eurostat.Economies.NETHERLANDS` |
| North Macedonia | MK | `Eurostat.Economies.NORTH_MACEDONIA` |
| 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` |
| Turkiye | TR | `Eurostat.Economies.TURKIYE` |

## Example Applications

The Business and Consumer Surveys dataset enables you to read business and consumer sentiment across Europe. Examples include the following strategies:

- Timing European equity or euro exposure on the direction of consumer confidence
- Reading price expectations across sectors as an early inflation signal
- Comparing business confidence across economies to rotate country exposure

### Classic Algorithm Example

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

```python
from AlgorithmImports import *

class EurostatSurveysExampleAlgorithm(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.consumer = self.add_data(EurostatConsumerSurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self.industry = self.add_data(EurostatIndustrySurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol

        self.previous_confidence = None

    def on_data(self, slice):
        industry = slice.get(EurostatIndustrySurvey)
        if self.industry in industry:
            data_point = industry[self.industry]
            self.debug(f"Industrial confidence: {data_point.industrial_confidence}, selling price expectations: {data_point.selling_price_expectation}")

        consumer = slice.get(EurostatConsumerSurvey)
        if self.consumer not in consumer:
            return

        confidence = consumer[self.consumer].consumer_confidence
        if confidence is None:
            return

        # Buy SPY when consumer confidence rises. Otherwise, liquidate.
        if self.previous_confidence is not None:
            if confidence > self.previous_confidence:
                self.set_holdings(self.equity, 1)
            else:
                self.liquidate(self.equity)

        self.previous_confidence = confidence
```

### Framework Algorithm Example

The following example algorithm emits up insights for SPY when German consumer and industrial confidence both rise. Otherwise, it emits flat insights.

```python
from AlgorithmImports import *

class EurostatSurveysFrameworkAlgorithm(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(EurostatConfidenceAlphaModel(self))

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

class EurostatConfidenceAlphaModel(AlphaModel):
    """Emits insights from German consumer and industrial confidence."""

    def __init__(self, algorithm):
        self._consumer = algorithm.add_data(EurostatConsumerSurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol
        self._industry = algorithm.add_data(EurostatIndustrySurvey, Eurostat.Economies.GERMANY, Resolution.DAILY).symbol

        history = algorithm.history(EurostatConsumerSurvey, self._consumer, timedelta(days=1825), Resolution.DAILY)
        algorithm.debug(f"Got {len(history)} historical consumer survey rows")

        self._previous_consumer = None
        self._previous_industry = None
        self._symbols = []

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

        consumer = data.get(EurostatConsumerSurvey)
        if self._consumer not in consumer:
            return insights

        confidence = consumer[self._consumer].consumer_confidence
        if confidence is None:
            return insights

        # Read the latest industrial confidence from the security cache.
        industry_point = algorithm.securities[self._industry].cache.get_data(EurostatIndustrySurvey)
        industrial = industry_point.industrial_confidence if industry_point else None

        if self._previous_consumer is not None:
            improving = confidence > self._previous_consumer
            if improving and industrial is not None and self._previous_industry is not None:
                improving = industrial > self._previous_industry

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

        self._previous_consumer = confidence
        if industrial is not None:
            self._previous_industry = industrial

        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 Business and Consumer Surveys dataset provides `EurostatConsumerSurvey`, `EurostatIndustrySurvey`, `EurostatConstructionSurvey`, `EurostatRetailSurvey`, and `EurostatServicesSurvey` objects.

### EurostatConsumerSurvey

`EurostatConsumerSurvey` objects have the following attributes:

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

### EurostatIndustrySurvey

`EurostatIndustrySurvey` objects have the following attributes:

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

### EurostatConstructionSurvey

`EurostatConstructionSurvey` objects have the following attributes:

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

### EurostatRetailSurvey

`EurostatRetailSurvey` objects have the following attributes:

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

### EurostatServicesSurvey

`EurostatServicesSurvey` objects have the following attributes:

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