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.
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 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
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}")
To iterate through all of the dataset objects in the current Slice
, call the get
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}")
Historical Data
To get historical Macroeconomic Indicators data, call the history
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)
For more information about historical data, see History Requests.
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.