EOD Historical Data

Economic Events

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.

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:

self.add_data(EODHDEconomicEvents, Country.UNITED_STATES)
self.add_data(EODHDEconomicEvents, EODHD.Events.UnitedStates.CPI) 
AddData<EODHDEconomicEvents>(Country.UnitedStates);
AddData<EODHDEconomicEvents>(EODHD.Events.UnitedStates.Cpi);

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 2019
Data DensitySparse
ResolutionDaily
TimezoneUTC

Example Applications

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

  • Long straddle to trade the volatility brought by the economic events.
  • Trade market representative ETFs upon estimate figures on the upcoming events.
  • Statistical arbitrage on 2 or more correlated global markets based on economic events of different locations.

For more example algorithms, see Examples.

Data Point Attributes

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

The EODHDEconomicEvents objects represent a collection of EODHDEconomicEvent object

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:

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:

Requesting Data

To add Economic Events data to your algorithm, call the AddData<EODHDUpcomingIPOs>add_data method.

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
namespace QuantConnect.Algorithm.CSharp.AltData
{
    public class EconomicEventsDataAlgorithm : QCAlgorithm
    {
        private Symbol _datasetSymbol;

        public override void Initialize()
        {
            SetStartDate(2019, 1, 1);
            SetEndDate(2020, 6, 1);
            SetCash(100000);

            var ticker = EODHD.Events.UnitedStates.Cpi;
            // var ticker = Country.UnitedStates;
            _datasetSymbol = AddData<EODHDEconomicEvents>(ticker).Symbol;
        }
    }
}

Accessing Data

To get the current Economic Events data, index the current Slice 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.

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}")
public override void OnData(Slice slice)
{
    if (slice.Get<EODHDEconomicEvents>().TryGetValue(_datasetSymbol, out var economicEvents))
    {
        foreach (EODHDEconomicEvent economicEvent in economicEvents)
        {
           Log($"{economicEvent.EventType} of {economicEvent.Country} over {economicEvent.EventPeriod} with be held at {economicEvent.EventTime} with estimated value {economicEvent.Estimate}");
        }
    }
}

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

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}")
public override void OnData(Slice slice)
{
    foreach (var (symbol, economicEvents) in slice.Get<EODHDEconomicEvents>())
    {
        foreach (EODHDEconomicEvent economicEvent in economicEvents)
        {
           Log($"{economicEvent.EventType} of {economicEvent.Country} over {economicEvent.EventPeriod} with be held at {economicEvent.EventTime} with estimated value {economicEvent.Estimate}");
        }
    }
}

Historical Data

To get historical Economic Events data, call the Historyhistory 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.

history_bars = self.history[EODHDEconomicEvents](self.dataset_symbol, 100, Resolution.DAILY)
var history = History<EODHDEconomicEvents>(_datasetSymbol, 100, Resolution.Daily);

For more information about historical data, see History Requests.

Remove Subscriptions

To remove a subscription, call the RemoveSecurityremove_security method.

self.remove_security(self.dataset_symbol)
RemoveSecurity(_datasetSymbol);

Example Applications

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

  • Long straddle to trade the volatility brought by the economic events.
  • Trade market representative ETFs upon estimate figures on the upcoming events.
  • Statistical arbitrage on 2 or more correlated global markets based on economic events of different locations.

For more example algorithms, see Examples.