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 or via the MCP
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', end_date="2025-12-31")
economics.get_government_debt(countries=['United States', 'Canada', 'Mexico'])
Or, after setting up the Finance Toolkit MCP, ask:
How large was the government debt of the United States, Canada and Mexico, in national currency, from 2015 to 2025?
Which returns:
| United States | Canada | Mexico | |
|---|---|---|---|
| 2015 | 1.92907e+07 | 1.83683e+06 | 9.80508e+06 |
| 2016 | 2.01975e+07 | 1.87318e+06 | 1.14065e+07 |
| 2017 | 2.08678e+07 | 1.94774e+06 | 1.184e+07 |
| 2018 | 2.22374e+07 | 2.02901e+06 | 1.26199e+07 |
| 2019 | 2.34322e+07 | 2.08475e+06 | 1.30327e+07 |
| 2020 | 2.83333e+07 | 2.62165e+06 | 1.40652e+07 |
| 2021 | 2.96684e+07 | 2.85548e+06 | 1.51339e+07 |
| 2022 | 3.10429e+07 | 2.96557e+06 | 1.58852e+07 |
| 2023 | 3.33635e+07 | 3.11556e+06 | 1.68118e+07 |
| 2024 | 3.58226e+07 | 3.41999e+06 | 1.97928e+07 |
| 2025 | 3.811e+07 | nan | nan |
Parameters
get_government_debt accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
countries | list[str] | str | None | A list of countries or a single country to include in the results. Defaults to None. | ["United States", "Germany"] |
level | str | The government the figures cover: “consolidated” (the Global Macro Database’s combination of general and central government figures, with the longest history), “general” (general government: central, state and local government and social security) or “central” (central government only). Defaults to “consolidated”. | "general" |
rolling | int | The rolling window size to use for smoothing the data (simple moving average). Defaults to None. | 4 |
trailing | int | The trailing window size to use for summing the data over trailing periods (e.g. a trailing-4-quarter sum). Defaults to None. | 4 |
growth | bool | Whether to return the growth data or the actual data. Defaults to False. | True |
lag | int | The number of periods to lag the growth data. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
gmdb_forecasts | bool | Whether to include the years the Global Macro Database projects, from the IMF’s World Economic Outlook, up to five years ahead. Only applies to data from the Global Macro Database. Defaults to False, which ends a series with its last observation. | True |