Debt to GDP
Get the Government Debt to GDP Ratio for a variety of countries over time from the Global Macro Database (GMDB). The Government Debt to GDP Ratio is the ratio of the total amount of money that a government owes to creditors to the Gross Domestic Product (GDP).
Debt to GDP is the standard measure of a government’s indebtedness, used by rating agencies, the IMF and the European Union, whose fiscal rules refer to 60% of GDP. Whether a ratio is sustainable depends less on its level than on the gap between the interest rate on the debt and the growth rate of nominal GDP, and on the primary balance. Compare countries on the same level of government (the level parameter), since central government debt can differ substantially from general government debt.
Data comes from the Global Macro Database (GMDB), further information about the variable can be found within https://www.globalmacrodata.com/documentation.html
The ratio is expressed as a decimal fraction (1.3173 for 131.73% of GDP).
The ratio is the Global Macro Database’s own figure, published in percent and divided by 100 here.
The formula is as follows:
\[\text{Government Debt to GDP Ratio} = \text{Gross Government Debt} / \text{Nominal GDP},\;\; \text{using the level of government selected with level ("consolidated" by default)}\]Also known as: debt-to-GDP ratio, fiscal sustainability.
Debt to GDP in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_government_debt_to_gdp_ratio as shown below.
from financetoolkit import Economics
economics = Economics(start_date='2015-01-01', end_date="2025-12-31")
economics.get_government_debt_to_gdp_ratio(countries=['Netherlands', 'Germany', 'China'])
Or, after setting up the Finance Toolkit MCP, ask:
How did government debt as a share of GDP develop in the Netherlands, Germany and China from 2015 to 2025?
Which returns:
| Netherlands | Germany | China | |
|---|---|---|---|
| 2015 | 0.6382 | 0.7118 | 0.4078 |
| 2016 | 0.6087 | 0.683 | 0.5003 |
| 2017 | 0.5597 | 0.6399 | 0.5389 |
| 2018 | 0.5155 | 0.6076 | 0.5588 |
| 2019 | 0.4765 | 0.5868 | 0.5984 |
| 2020 | 0.5341 | 0.6804 | 0.7013 |
| 2021 | 0.505 | 0.6794 | 0.7213 |
| 2022 | 0.4841 | 0.644 | 0.7729 |
| 2023 | 0.4585 | 0.6235 | 0.8408 |
| 2024 | 0.4378 | 0.6223 | 0.9042 |
| 2025 | 0.4439 | 0.635 | nan |
Parameters
get_government_debt_to_gdp_ratio 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 |