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.

ParameterTypeDescriptionExample
countrieslist[str] | str | NoneA list of countries or a single country to include in the results. Defaults to None.["United States", "Germany"]
levelstrThe 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"
rollingintThe rolling window size to use for smoothing the data (simple moving average). Defaults to None.4
trailingintThe trailing window size to use for summing the data over trailing periods (e.g. a trailing-4-quarter sum). Defaults to None.4
growthboolWhether to return the growth data or the actual data. Defaults to False.True
lagintThe number of periods to lag the growth data. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None.2
gmdb_forecastsboolWhether 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
Share