---
title: "Economic Events"
description: "Economic Events dataset from EOD Historical Data."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eod-historical-data/economic-events
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eod-historical-data/economic-events.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/12%20EOD%20Historical%20Data/01%20Economic%20Events
modified: 2026-10-31
index: https://www.quantconnect.com/llms.txt
---

# Economic Events

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [EOD Historical Data](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eod-historical-data.md) > Economic Events

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

## Introduction

The Economic Events dataset, provided by EODHD, offers daily alerts for major economic events or announcements of global markets within the upcoming 7 days, with estimation and previous record if available. The data starts in January 2019, and is delivered on a daily frequency.

For more information about the Economic Events dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/eodhd-economic-events).

## About the Provider

EODHD was a France financial data provider founded in April 2015. They focus on providing clean financial data, including stock prices, splits, dividends, fundamentals, macroeconomy indicators, technical indicators, and alternative data sources, through 24/7 API seamlessly.

## Getting Started

The following snippet demonstrates how to request data from the Economic Events dataset:

```python
self.add_data(EODHDEconomicEvents, Country.UNITED_STATES)
self.add_data(EODHDEconomicEvents, EODHD.Events.UnitedStates.CPI)
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 2019 |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | UTC |

## Requesting Data

To add Economic Events data to your algorithm, call the `add_data` method.

```python
class EconomicEventsDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2020, 6, 1)
        self.set_cash(100000)

        ticker = EODHD.Events.UnitedStates.CPI
        # ticker = Country.UNITED_STATES
        self.dataset_symbol = self.add_data(EODHDEconomicEvents, ticker).symbol
```

## Accessing Data

To get the current Economic Events 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:
    events = slice.get(EODHDEconomicEvents).get(self.dataset_symbol)
    for event in events:
        self.log(f"{event.event_type} of {event.country} over {event.event_period} with be held at {event.event_time} with estimated value {event.estimate}")
```

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 symbol, events in slice.get(EODHDEconomicEvents).items():
        for event in events:
            self.log(f"{event.event_type} of {event.country} over {event.event_period} with be held at {event.event_time} with estimated value {event.estimate}")
```

## Historical Data

To get historical Economic Events data, call the `history` method with the type `EODHDEconomicEvents` cast and the underlying `Symbol`. If there is no data in the period you request, the history result is empty.

```python
history_bars = self.history[EODHDEconomicEvents](self.dataset_symbol, 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 a subscription, call the `remove_security` method.

```python
self.remove_security(self.dataset_symbol)
```

## Example Applications

The Economic Events dataset provides timely notifications about upcoming economic events, allowing traders to trade on that volatility. Examples include the following strategies:

- Long straddle to trade the volatility of the economic events.
- Trade market representative ETFs based on estimated figures for the upcoming events.
- Statistical arbitrage on two or more correlated global markets based on economic events of different locations.

### Classic Algorithm Example

The following example algorithm trade Industrial sector ETF based on US PMI estimated change direction. If the estimated PMI of the upcoming announcement is above the previous PMI, buy the Industrial ETF, and sell it otherwise.

```python
from AlgorithmImports import *

class EODHDEconomicEventsAlgorithm(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Use industrial sector ETF as a vehicle to trade.
        self.equity_symbol = self.add_equity("XLI").symbol
        # Request US PMI economic event data to generate trade signals.
        ticker = EODHD.Events.UnitedStates.MARKIT_MANUFACTURING_PURCHASING_MANAGERS_INDEX
        self.dataset_symbol = self.add_data(EODHDEconomicEvents, ticker).symbol

    def on_data(self, slice):
        # Trade based on the updated economic events.
        if self.dataset_symbol in slice.get(EODHDEconomicEvents):
            # Use the Manufacturing Index to generate trade signals on manufacturing industry vehicles.
            # Make sure previous and estimate are available to estimate the direction of the industry.
            event = slice[self.dataset_symbol].data[0]
            if event.previous and event.estimate:
                # If the estimated PMI is higher than the previous PMI, the manufacturing ETF price is expected to rise.
                if event.previous > event.estimate:
                    self.set_holdings(self.equity_symbol, 1)
                # Otherwise, it is expected manufacturing ETF prices will drop.
                else:
                    self.set_holdings(self.equity_symbol, -1)
```

### Framework Algorithm Example

The following example algorithm trade Industrial sector ETF based on US PMI estimated change direction using algorithm framework. If the estimated PMI of the upcoming announcement is above the previous PMI, buy the Industrial ETF, sell it otherwise.

```python
from AlgorithmImports import *

class EODHDEconomicEventsAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Use industrial sector ETF as a vehicle to trade.
        symbol = Symbol.create("XLI", SecurityType.EQUITY, Market.USA)
        self.add_universe_selection(ManualUniverseSelectionModel(symbol))
        # Custom alpha model to emit insights according to economic events.
        self.add_alpha(EconomicEventAlphaModel(self))
        # Equal weighting position sizing to dissipate capital risk evenly.
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(Expiry.END_OF_MONTH))

class EconomicEventAlphaModel(AlphaModel):
    def __init__(self, algorithm: QCAlgorithm) -> None:
        # Request US PMI economic event data to generate trade signals.
        ticker = EODHD.Events.UnitedStates.MARKIT_MANUFACTURING_PURCHASING_MANAGERS_INDEX
        self.dataset_symbol = algorithm.add_data(EODHDEconomicEvents, ticker).symbol
        self._symbol = None

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        # Trade based on the updated economic events.
        if self.dataset_symbol not in slice.get(EODHDEconomicEvents):
            return []
        # Use the US Manufacturing Index to generate trade signals on manufacturing industry vehicles.
        # Make sure previous and estimate are available to estimate the direction of the industry.
        event = slice[self.dataset_symbol].data[0]
        # If the estimated PMI is higher than the previous PMI, the manufacturing ETF price is expected to rise.
        # Otherwise, it is expected manufacturing ETF prices will drop.
        direction = InsightDirection.UP if event.previous > event.estimate else InsightDirection.DOWN
        return [Insight.price(self._symbol, timedelta(5), direction)]

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for added in changes.added_securities:
            self._symbol = added.symbol
```

## Data Point Attributes

The EODHD Economic Events dataset provides `EODHDEconomicEvent` objects, which have the following attributes:

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

The `EODHDEconomicEvents` objects represent a collection of `EODHDEconomicEvent` object

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

### Country Enumeration

To filter the countries of the economic events, you can make use of the `Country` enumeration. The `Country` enumeration has the following members:

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

### Events Enumeration

To filter the event types of the economic events, you can make use of the `Events` enumeration. The `Events` enumeration has the following members:

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