Government Deficit
Get the Government Deficit for a variety of countries over time from the Global Macro Database (GMDB). Government Deficit is the total amount of money that a government spends more than it collects from taxes and other sources. A government deficit is usually financed by borrowing money.
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, in millions of national currency: a negative value is a deficit (spending exceeding revenue) and a positive value is a surplus.
Also known as: budget deficit, fiscal deficit.
Government Deficit in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_government_deficit as shown below.
from financetoolkit import Economics
economics = Economics(start_date='2015-01-01', end_date="2025-12-31")
economics.get_government_deficit(countries=['United States', 'Canada', 'Mexico'])
Or, after setting up the Finance Toolkit MCP, ask:
How large was the government budget balance of the United States, Canada and Mexico each year, in national currency, from 2015 to 2025?
Which returns:
| United States | Canada | Mexico | |
|---|---|---|---|
| 2015 | -853792 | -1231 | -742271 |
| 2016 | -1.02094e+06 | -9182 | -556067 |
| 2017 | -872728 | -2401 | -233109 |
| 2018 | -1.27096e+06 | 8046 | -517006 |
| 2019 | -1.44074e+06 | -400 | -569358 |
| 2020 | -3.20097e+06 | -243127 | -1.03224e+06 |
| 2021 | -2.82551e+06 | -77523 | -1.00013e+06 |
| 2022 | -961028 | 17672 | -1.27619e+06 |
| 2023 | -2.18266e+06 | -4808 | -1.36965e+06 |
| 2024 | -2.31875e+06 | -65919 | -1.93368e+06 |
| 2025 | -2.23721e+06 | -57263 | nan |
Parameters
get_government_deficit 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 |