Government Debt
Get the Government Debt for a variety of countries over time from the Global Macro Database (GMDB). Government Debt is the total amount of money that a government owes to creditors.
The stock is annual and expressed in millions of national currency, so levels are not comparable across countries with different currencies, but growth rates are.
Data comes from the Global Macro Database (GMDB), further information about the variable can be found within https://www.globalmacrodata.com/documentation.html
Also known as: national debt, sovereign debt.
Government Debt in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_government_debt as shown below.
from financetoolkit import Economics
economics = Economics(start_date='2015-01-01')
economics.get_government_debt(countries=['United States', 'Canada', 'Mexico'])
Which returns:
| United States | Canada | Mexico | |
|---|---|---|---|
| 2015 | 1.91477e+07 | 1.83178e+06 | 9.8014e+06 |
| 2016 | 2.00426e+07 | 1.87153e+06 | 1.1418e+07 |
| 2017 | 2.06965e+07 | 1.94674e+06 | 1.18362e+07 |
| 2018 | 2.20709e+07 | 2.02946e+06 | 1.26207e+07 |
| 2019 | 2.3264e+07 | 2.08707e+06 | 1.30389e+07 |
| 2020 | 2.81514e+07 | 2.62466e+06 | 1.4089e+07 |
| 2021 | 2.94887e+07 | 2.85651e+06 | 1.51449e+07 |
| 2022 | 3.08486e+07 | 3.02057e+06 | 1.59543e+07 |
| 2023 | 3.29114e+07 | 3.10891e+06 | 1.68674e+07 |
| 2024 | 3.52945e+07 | 3.20199e+06 | 1.97489e+07 |
| 2025 | 3.76545e+07 | 3.26736e+06 | 2.12283e+07 |
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.
- 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.