Gross Domestic Product (GDP)
Get the Gross Domestic Product for a variety of countries over time from the OECD. The Gross Domestic Product is the total value of goods produced and services provided in a country during one year.
Note that the OECD source reports GDP on a per capita basis, i.e. the total Gross Domestic Product divided by the population of the country, whereas the Global Macro Database (GMDB) source reports the total (not per capita) figure. The two are also expressed in different units: the OECD source is in current-price US dollars per person converted with Purchasing Power Parities (PPPs), which makes the level comparable across countries, while the GMDB source is in millions of national currency. Both are annual.
The data is returned as levels. To obtain period-on-period changes (e.g. year on year or quarter on quarter growth), set growth=True and use lag to control how many periods back the comparison is made.
See definition: https://data.oecd.org/gdp/gross-domestic-product-gdp.htm
It is also possible to acquire the data from the Global Macro Database (GMDB) source which also provides inflation adjusted data. For more information see: https://www.globalmacrodata.com/documentation.html
Also known as: GDP, national income, economic growth.
Gross Domestic Product (GDP) in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_gross_domestic_product as shown below.
from financetoolkit import Economics
economics = Economics(start_date='2015-01-01')
economics.get_gross_domestic_product(inflation_adjusted=True, countries=['Netherlands', 'Germany', 'China'])
Which returns:
| Netherlands | Germany | China | |
|---|---|---|---|
| 2015 | 792438 | 3.35252e+06 | 6.92094e+07 |
| 2016 | 811653 | 3.42927e+06 | 7.39494e+07 |
| 2017 | 834241 | 3.52232e+06 | 7.90868e+07 |
| 2018 | 853097 | 3.56164e+06 | 8.44244e+07 |
| 2019 | 872718 | 3.597e+06 | 8.94487e+07 |
| 2020 | 838886 | 3.44953e+06 | 9.14542e+07 |
| 2021 | 891550 | 3.57614e+06 | 9.91816e+07 |
| 2022 | 936192 | 3.62504e+06 | 1.02108e+08 |
| 2023 | 936871 | 3.61547e+06 | 1.07468e+08 |
| 2024 | 942765 | 3.61572e+06 | 1.12652e+08 |
| 2025 | 958100 | 3.64414e+06 | 1.17704e+08 |
Parameters
The function accepts the following parameters:
- countries (list[str] | str | None, optional): A list of countries or a single country to include in the results. Defaults to None.
- inflation_adjusted (bool, optional): Whether to return the inflation adjusted data. Defaults to False.
- gmdb_source (bool | None, optional): If True, retrieves data from the GMDB source. Defaults to None.
- rolling (int, optional): The rolling window size to use for smoothing the data (simple moving average). Defaults to None.
- trailing (int, optional): The trailing window size to use for summing the data over trailing periods (e.g. a trailing-4-quarter sum). Defaults to None.
- growth (bool, optional): Whether to return the growth data or the actual data. Defaults to False.
- lag (int, optional): The number of periods to lag the growth data. Defaults to 1.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.