Skip to main content

Economy

The Economy module wraps the functions from the Economy menu of the OpenBB Terminal, and provides the user with more control over their workflow. In a Jupyter Notebook environment, it is quick and easy to get going. To get the most out of these functions, it is highly recommended to acquire API keys for:

Define the keys for the OpenBB installation with:


openbb.keys.fred(key = 'REPLACE_ME', persist = True)
openbb.keys.quandl(key = 'REPLACE_ME', persist = True)
openbb.keys.av(key = 'REPLACE_ME', persist = True)

How to Use

Below is brief description of each function within the Economy module:

PathTypeDescription
openbb.economy.available_indicesDictionaryCurated List of Global Indices
openbb.economy.balanceFunctionGlobal Government Deficit/Surplus
openbb.economy.balance_chartFunctionChart for balance
openbb.economy.bigmacFunctionThe Big Mac Index
openbb.economy.bigmac_chartFunctionChart for bigmac
openbb.economy.ccpiFunctionCPI Components Data by Country
openbb.economy.ccpi_chartFunctionChart for ccpi
openbb.economy.country_codesFunctionList of Three-Letter ISO Country Codes
openbb.economy.cpiFunctionHarmonized CPI Data by Country
openbb.economy.cpi_chartFunctionChart for cpi
openbb.economy.currenciesFunctionCurrencies from WSJ
openbb.economy.debtFunctionGovernment Debt-to-GDP Ratio
openbb.economy.debt_chartFunctionChart for debt
openbb.economy.eventsFunctionEconomic Calendar
openbb.economy.fgdpFunctionReal GDP Forecast by Country
openbb.economy.fgdp_chartFunctionChart for fgdp
openbb.economy.fredFunctionGet FRED series data
openbb.economy.fred_idsFunctionSearch for a FRED series ID by keyword
openbb.economy.fred_notesFunctionSearch by Keyword for Series Information
openbb.economy.futureFunctionCurrent Prices of Commodities and Futures from FinViz
openbb.economy.futuresFunctionCurrent Prices of Commodities and Futures from WSJ
openbb.economy.gdpFunctionUS GDP per Capita from AlphaVantage
openbb.economy.gdp_chartFunctionChart for gdp
openbb.economy.get_groupsListList of Groups for Performance and Valuation Functions
openbb.economy.glbondsFunctionTable of Select 10 Year Sovereign Bonds from WSJ
openbb.economy.indexFunctionHistorical Daily Data for Indices from YahooFinance
openbb.economy.index_chartFunctionChart for index
openbb.economy.indicesFunctionTop US Indices from WSJ
openbb.economy.macroFunctionGets Series Data from EconDB
openbb.economy.macro_chartFunctionChart for macro
openbb.economy.macro_countriesListList of Countries Accepted by Macro Function
openbb.economy.macro_parametersDictionaryDictionary of Parameters & Descriptions for Macro Function
openbb.economy.overviewFunctionGeneral Market Overview from WSJ
openbb.economy.perfmapFunctionOpens a Browser to Performance Map from Finviz
openbb.economy.performanceFunctionPerformance Data (get_groups)
openbb.economy.revenueFunctionGovernment Revenues by Country
openbb.economy.revenue_chartFunctionChart for revenue
openbb.economy.rgdpFunctionReal GDP by Country
openbb.economy.rgdp_chartFunctionChart for rgdp
openbb.economy.search_indexFunctionSearch for a Global Index by Name
openbb.economy.spendingFunctionGeneral Government Spending by Year and Country
openbb.economy.spending_chartFunctionChart for spending
openbb.economy.treasuryFunctionUS Treasuries Data
openbb.economy.treasury_chartFunctionChart for treasury
openbb.economy.treasury_maturitiesFunctionTable of Accepted Values for Maturities Argument in treasury
openbb.economy.trustFunctionTrust in Government (OECD) as a % by Country
openbb.economy.trust_chartFunctionChart for trust
openbb.economy.usbondsFunctionTable of Current Rate, Yield, and Yield Change
openbb.economy.usdliFunctionThe USD Liquidity Index
openbb.economy.usdli_chartFunctionChart for usdli
openbb.economy.valuationFunctionValuation for Group from (get_gropus)

Alternatively, the contents of the economy, or function docstrings, is printed with:

help(openbb.economy)

Examples

Import Statements

The examples will assume that this code block is included with the import statements:

from openbb_terminal.sdk import openbb
import pandas as pd

Index

The index function can request data using a couple of methods. There is a curated list of global indexes which can be entered by symbol or values from the left column of the table below.

indexes = pd.DataFrame.from_dict(openbb.economy.available_indices()).transpose()

indexes
nameticker
sp500S&P 500 Index^GSPC
sp400S&P 400 Mid Cap Index^SP400
sp600S&P 600 Small Cap Index^SP600
sp500trS&P 500 TR Index^SP500TR
sp_xspS&P 500 Mini SPX Options Index^XSP
cboe_tyxCBOE 30 year Treasury Yields^TYX
cboe_irxCBOE 13 Week Treasury Bill^IRX
moveICE BofAML Move Index^MOVE
dxyUS Dollar IndexDX-Y.NYB
crypto200CMC Crypto 200 Index by Solacti^CMC200

This list can be filtered:

filtered = indexes.name.str.contains('s&p', case = False)
indexes[filtered].head(10)
nameticker
sp500S&P 500 Index^GSPC
sp400S&P 400 Mid Cap Index^SP400
sp600S&P 600 Small Cap Index^SP600
sp500trS&P 500 TR Index^SP500TR
sp_xspS&P 500 Mini SPX Options Index^XSP
ca_banksS&P/TSX Composite Banks Index (CAD)TXBA.TS
ar_mervelS&P MERVAL TR Index (USD)M.BA
eu_speupS&P Europe 350 Index (EUR)^SPEUP
uk_spukS&P United Kingdom Index (PDS)^SPUK
in_bseS&P Bombay SENSEX (INR)^BSESN

One index, or multiple, can be requested as a single DataFrame:

df = openbb.economy.index(indices = ['sp_energy_oil', 'sp_energy_equipment', 'sp_energy_ig'])

df.tail(3)
Datesp_energy_oilsp_energy_equipmentsp_energy_ig
2022-11-14 00:00:00800.76330.53712.28
2022-11-15 00:00:00809.27335.84720.16
2022-11-16 00:00:00792.32326.49704.68

This can also be displayed as a chart:

openbb.economy.index_chart(indices = ['sp_energy_oil', 'sp_energy_equipment', 'sp_energy_ig'])

openbb.economy.index_chart

Performance

Performance metrics for sectors, industries, and regions (US listed) are printed with:

openbb.economy.performance(group = 'energy')
NameWeekMonth3Month6Month1YearYTDRecomAvgVolume [1M]RelVolumeChangeVolume [1M]
0Oil & Gas Drilling0.01060.21540.25010.15340.7110.89911.9233.580.71-0.01316.93
1Oil & Gas E&P0.00190.06180.11880.150.66020.69222.18287.090.66-0.0059136.36
2Oil & Gas Equipment & Services-0.00630.16130.3050.12190.4930.57022.174.10.52-0.012527.79
3Oil & Gas Integrated0.01660.05570.08850.04620.40140.41142.23122.440.71-0.007962.12
4Oil & Gas Midstream-0.01130.038-0.0190.00450.15510.20272.3105.550.65-0.011548.8
5Oil & Gas Refining & Marketing0.01470.09290.15620.15850.60380.60842.1330.590.61-0.000613.32
6Thermal Coal-0.00960.0291-0.04940.12891.23051.05041.978.740.69-0.02074.28
7Uranium-0.01760.04160.08560.0426-0.17460.02671.6132.440.54-0.012512.58

Performance by sector:

openbb.economy.performance(group = 'sector')
NameWeekMonth3Month6Month1YearYTDRecomAvgVolume [1M]RelVolumeChangeVolume [1M]
0Basic Materials-0.00320.1290.0195-0.0572-0.0684-0.09282.22469.940.66-0.0116222.2
1Communication Services0.03430.0128-0.1444-0.1297-0.3837-0.35291.97731.340.720.0004377.12
2Consumer Cyclical0.01110.0266-0.1386-0.0182-0.3665-0.32212.1414301.01-0.00341040
3Consumer Defensive0.0030.0757-0.03020.0573-0.019-0.05742.31298.740.85-0.0019181.95
4Energy0.00670.06290.09130.07360.42080.44972.21694.520.65-0.008322.19
5Financial-0.00950.0934-0.00980.0339-0.1259-0.11372.24861.740.79-0.005489.78
6Healthcare-0.01210.0703-0.01250.0177-0.1074-0.11612.1111800.870.0002736.58
7Industrials-0.01180.0969-0.02230.0723-0.1138-0.1012.32573.080.7-0.005285.24
8Real Estate-0.02590.0884-0.1441-0.0961-0.2413-0.27382.18341.840.55-0.0055134.66
9Technology0.01490.0938-0.1095-0.0044-0.3024-0.29572.0314600.860.0039904.44
10Utilities-0.02350.0485-0.1212-0.0582-0.0054-0.05692.29166.210.67-0.014279.25

Events

A global economic calendar is accessible through the events function:

help(openbb.economy.events)

Help on Operation in module openbb_terminal.core.library.operation:

<openbb_terminal.core.library.operation.Operation object>
Get economic calendar for countries between specified dates

Parameters
----------
countries : [List[str],str]
List of countries to include in calendar. Empty returns all
start_date : str
Start date for calendar
end_date : str
End date for calendar

Returns
-------
pd.DataFrame
Economic calendar

With no arguments, events will return the calendar from today:

openbb.economy.events().head(10)
Time (ET)CountryEventActualConsensusPreviousDate
001:45GermanyGerman Buba President Nagel Speaks---2023-04-13
101:45GermanyGerman Buba Vice President Buch Speaks---2023-04-13
202:00United KingdomConstruction Output2.4%0.9%-1.7%2023-04-13
302:00United KingdomU.K. Construction Output5.7%1.6%3.3%2023-04-13
402:00United KingdomGDP0.0%0.1%0.4%2023-04-13
502:00United KingdomIndex of Services0.1%-0.2%0.1%2023-04-13
602:00United KingdomIndustrial Production-0.2%0.2%-0.5%2023-04-13
702:00United KingdomIndustrial Production-3.1%-3.7%-3.2%2023-04-13
802:00United KingdomManufacturing Production-2.4%-4.7%-2.8%2023-04-13
902:00United KingdomManufacturing Production0.0%0.2%-0.1%2023-04-13

Calendar events can be requested for a specific countries and date ranges:

openbb.economy.events(countries = ['United States'], start_date = '2022-11-18', end_date = '2022-11-18').head(5)
Time (ET)CountryEventActualConsensusPreviousDate
009:40United StatesFed Collins Speaks---2022-11-18
111:00United StatesExisting Home Sales-5.9%--1.5%2022-11-18
211:00United StatesExisting Home Sales4.43M4.38M4.71M2022-11-18
311:00United StatesUS Leading Index-0.8%-0.4%-0.5%2022-11-18
414:00United StatesU.S. Baker Hughes Oil Rig Count623-6222022-11-18

FRED

Search the FRED database for a series titles containing keywords:

series_ids = openbb.economy.fred_ids(search_query = 'Oil and Gas')

series_ids.head(5)
idtitle
PCU333132333132Producer Price Index by Industry: Oil and Gas Field Machinery and Equipment Manufacturing
CES1021100001All Employees, Oil and Gas Extraction
IPG211111CSIndustrial Production: Mining, Quarrying, and Oil and Gas Extraction: Crude Oil (NAICS = 211111pt.)
A33DNOManufacturers' New Orders: Mining, Oil, and Gas Field Machinery Manufacturing
PCU21112111Producer Price Index by Industry: Oil and Gas Extraction

Macro

The macro function will return a Tuple. See refer to the docstring below to see the input arguments:

help(openbb.economy.macro)

Help on Operation in module openbb_terminal.core.library.operation:

<openbb_terminal.core.library.operation.Operation object>
Use 'economy.macro_chart' to access the view.
This functions groups the data queried from the EconDB database [Source: EconDB]

Parameters
----------
parameters: list
The type of data you wish to download. Available parameters can be accessed through economy.macro_parameters().
countries : list
The selected country or countries. Available countries can be accessed through economy.macro_countries().
transform : str
The selected transform. Available transforms can be accessed through get_macro_transform().
start_date : str
The starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31.
end_date : str
The end date, format "YEAR-MONTH-DAY", i.e. 2020-06-05.
symbol : str
In what currency you wish to convert all values.

Returns
-------
Tuple[pd.DataFrame, Dict[Any, Dict[Any, Any]], str]
A DataFrame with the requested macro data of all chosen countries,
A dictionary containing the units of each country's parameter (e.g. EUR),
A string denomination which can be Trillions, Billions, Millions, Thousands

Examples
--------
>>> from openbb_terminal.sdk import openbb
>>> macro_df = openbb.economy.macro()

openbb.economy.macro_parameters() will return a list of dictionaries. Read it as a DataFrame with:

parameters = pd.DataFrame.from_dict(openbb.economy.macro_parameters()).transpose()

parameters.tail(5)
nameperioddescription
Y10YDLong term yield (10-year)MonthlyThe 10-year yield is used as a proxy for mortgage rates. It's also seen as a sign of investor sentiment about the country's economy.
M3YD3 month yieldMonthlyThe yield received for investing in a government issued treasury security that has a maturity of 3 months
HOUHouse price indexMonthlyHouse price index defined with base 2015 for Europe with varying bases for others. See: https://www.econdb.com/main-indicators
OILPRODOil productionMonthlyThe amount of oil barrels produced per day in a month within a country.
POPPopulationMonthlyThe population of a country. This can be in thousands or, when relatively small, in actual units.

The data from the macro function is unpacked like:

data,units,denomination = openbb.economy.macro(parameters = ['Y10YD'], countries = ['United States', 'Poland', 'France', 'Italy', 'Spain', 'Germany'])

data.tail(10)
dateFranceGermanyItalyPolandSpainUnited States
2022-05-011.520.952.996.642.042.9
2022-06-012.061.453.647.142.633.14
2022-07-011.711.083.366.372.312.9
2022-08-011.691.033.35.82.152.9
2022-09-012.411.84.146.282.923.52
2022-10-012.772.194.537.823.293.98
2022-11-012.582.074.247.243.073.89
2022-12-012.622.094.266.613.093.62
2023-01-012.692.194.246.023.23.53
2023-02-012.872.374.276.183.393.75