EOD Historical Data

Macroeconomics Indicators

Introduction

The Macroeconomic Indicators dataset, provided by EODHD, provides data on 39 major macroeconomic indicators of 249 countries and regions. The data starts in January 1998, and is delivered on indicators update.

For more information about the Macroeconomics Indicators 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 Macroeconomic Indicators dataset:

self.add_data(EODHDMacroIndicators, Country.UNITED_STATES)
self.add_data(EODHDMacroIndicators, EODHD.MacroIndicators.UnitedStates.GDP_CURRENT_USD) 
AddData<EODHDMacroIndicators>(Country.UnitedStates);
AddData<EODHDMacroIndicators>(EODHD.MacroIndicators.UnitedStates.GdpCurrentUsd);

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 1998
Data DensitySparse
ResolutionDaily
TimezoneUTC

Example Applications

The Macroeconomic Indicators dataset provides data on global macro indicators, allowing traders to react on market sentiment. Examples include the following strategies:

  • Long straddle to trade the market shock brought by the macro indicators.
  • Hold long or short position of the market representative ETF based on the expected market direction.
  • Statistical arbitrage on 2 or more correlated global markets based on market strength indicated by macro indicators.

For more example algorithms, see Examples.

Data Point Attributes

The EODHD Macro Indicators dataset provides EODHDMacroIndicators objects, which have the following attributes:

MacroIndicators Enumeration

To filter the specific indicator, you can make use of the MacroIndicators enumeration. The MacroIndicators enumeration has the following members:

Country Enumeration

To filter the country of the macro indicators, you can make use of the Country enumeration. The Country enumeration has the following members:

Frequency Enumeration

To filter the indicator frequency of the macro indicators, you can make use of the Frequency enumeration. The Frequency enumeration has the following members:

Requesting Data

To add Macroeconomic Indicators data to your algorithm, call the AddData<EODHDMacroIndicators>add_data method.

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

        self.dataset_symbol = self.add_data(
            EODHDMacroIndicators,
            EODHD.MacroIndicators.UnitedStates.GDP_CURRENT_USD    # Country.UNITED_STATES
        ).symbol
namespace QuantConnect.Algorithm.CSharp.AltData
{
    public class EODHDMacroIndicatorsAlgorithm : QCAlgorithm
    {
        private Symbol _datasetSymbol;

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

            _datasetSymbol = AddData<EODHDMacroIndicators>(
                EODHD.MacroIndicators.UnitedStates.GdpCurrentUsd
            ).Symbol;
            // _datasetSymbol = AddData<EODHDMacroIndicators>(Country.UnitedStates).Symbol;
        }
    }
}

Accessing Data

To get the current Macroeconomic Indicators 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:
    if slice.contains_key(self.dataset_symbol):
        data_point = slice[self.dataset_symbol]
        self.log(f"{data_point.frequency} {data_point.indicator} of {data_point.country} at {data_point.time} with value {data_point.value}")
public override void OnData(Slice slice)
{
    if (slice.ContainsKey(_datasetSymbol))
    {
        var dataPoint = slice[_datasetSymbol];
        Log($"{dataPoint.Frequency} {dataPoint.Indicator} of {dataPoint.Country} at {dataPoint.Time} with value {dataPoint.Value}");
    }
}

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

def on_data(self, slice: Slice) -> None:
    for _, data_point in slice.get(EODHDMacroIndicators).items():
        self.log(f"{data_point.frequency} {data_point.indicator} of {data_point.country} at {data_point.time} with value {data_point.value}")
public override void OnData(Slice slice)
{
    foreach (var kvp in slice.Get<EODHDMacroIndicators>())
    {
        var eventDataPoint = kvp.Value;
        Log($"{dataPoint.Frequency} {dataPoint.Indicator} of {dataPoint.Country} at {dataPoint.Time} with value {dataPoint.Value}");
    }
}

Historical Data

To get historical Macroeconomic Indicators data, call the Historyhistory method with the type EODHDMacroIndicators cast and the underlying Symbol. If there is no data in the period you request, the history result is empty.

history_bars = self.history[EODHDMacroIndicators](self.dataset_symbol, 100)
var history = History<EODHDMacroIndicators>(_datasetSymbol, 100);

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 Macroeconomic Indicators dataset provides data on global macro indicators, allowing traders to react on market sentiment. Examples include the following strategies:

  • Long straddle to trade the market shock brought by the macro indicators.
  • Hold long or short position of the market representative ETF based on the expected market direction.
  • Statistical arbitrage on 2 or more correlated global markets based on market strength indicated by macro indicators.

For more example algorithms, see Examples.