Deficit to GDP
Get the Government Deficit to GDP Ratio for a variety of countries over time from the Global Macro Database (GMDB). The Government Deficit to GDP Ratio is the ratio of the total amount of money that a government spends more than it collects from taxes and other sources to the Gross Domestic Product (GDP). A government deficit is usually financed by borrowing money.
The budget balance as a share of GDP is the headline fiscal indicator, with the European Union’s 3% of GDP as the best-known reference for deficits. It includes interest payments and moves with the business cycle, so analysts also look at the primary balance (excluding interest) and the cyclically adjusted balance to judge the fiscal stance. A deficit that stays above the nominal growth rate times the debt ratio keeps pushing debt to GDP up.
Data comes from the Global Macro Database (GMDB), further information about the variable can be found within https://www.globalmacrodata.com/documentation.html
The series is signed as a fiscal balance rather than as a deficit, and expressed as a decimal fraction of GDP: -0.07068 means a deficit of 7.068% of GDP, and a positive value is a surplus.
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 Deficit to GDP Ratio} = (\text{Government Revenue} - \text{Government Expenditure}) / \text{Nominal GDP},\;\; \text{using the level of government selected with level ("consolidated" by default)}\]Also known as: deficit-to-GDP, fiscal balance.
Deficit to GDP in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_government_deficit_to_gdp_ratio as shown below.
from financetoolkit import Economics
economics = Economics(start_date='2015-01-01', end_date="2025-12-31")
government_deficit_to_gdp_ratio = economics.get_government_deficit_to_gdp_ratio()
government_deficit_to_gdp_ratio.loc[:, ['New Zealand', 'Australia', 'United Kingdom']]
Or, after setting up the Finance Toolkit MCP, ask:
How did the government budget balance as a share of GDP compare in New Zealand, Australia and the United Kingdom from 2015 to 2025?
Which returns:
| New Zealand | Australia | United Kingdom | |
|---|---|---|---|
| 2015 | 0.0012 | -0.0104 | -0.045 |
| 2016 | 0.0115 | -0.0155 | -0.0327 |
| 2017 | 0.0162 | -0.0063 | -0.0246 |
| 2018 | 0.0083 | -0.0056 | -0.0219 |
| 2019 | -0.0028 | -0.0121 | -0.0246 |
| 2020 | -0.0758 | -0.1142 | -0.1291 |
| 2021 | -0.0388 | -0.0417 | -0.0774 |
| 2022 | -0.0292 | -0.0193 | -0.0473 |
| 2023 | -0.0348 | -0.0135 | -0.0604 |
| 2024 | -0.0299 | -0.0277 | -0.0613 |
| 2025 | -0.0333 | -0.0393 | -0.0546 |
Parameters
get_government_deficit_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 |