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.

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.

Changed in v2.2.0: this used to be returned in percentage points. It is now a decimal fraction, matching every other ratio in the Finance Toolkit.

Also known as: deficit-to-GDP, fiscal balance.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Deficit to GDP for you. Just ask in plain English.

Calculate the Deficit to GDP in Python

The Deficit to GDP is available in the Economics module of the open-source Finance Toolkit. Install it 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')

government_deficit_to_gdp_ratio = economics.get_government_deficit_to_gdp_ratio()

government_deficit_to_gdp_ratio.loc[:, ['New Zealand', 'Australia', 'United Kingdom']]

Which returns:

  New Zealand Australia United Kingdom
2015 0.0036 -0.0278 -0.0462
2016 0.0098 -0.0242 -0.0334
2017 0.0136 -0.0172 -0.0251
2018 0.0127 -0.0126 -0.0227
2019 -0.025 -0.044 -0.0248
2020 -0.0433 -0.0872 -0.1314
2021 -0.0324 -0.0635 -0.0786
2022 -0.0351 -0.0219 -0.047
2023 -0.0333 -0.0086 -0.0596
2024 -0.0384 -0.0166 -0.0425
2025 -0.0349 -0.0204 -0.0374
2026 -0.0234 -0.013 -0.0354

Parameters

get_government_deficit_to_gdp_ratio accepts the following parameters:

  • countries (list[str] | str | None, optional): A list of countries or a single country to include in the results. Defaults to None.
  • rolling (int, optional): The rolling window size to use for smoothing the data (simple moving average). Defaults to None.
  • trailing (int, optional): The trailing window size to use for summing the data over trailing periods (e.g. a trailing-4-quarter sum). Defaults to None.
  • growth (bool, optional): Whether to return the growth data or the actual data. Defaults to False.
  • lag (int, optional): The number of periods to lag the growth data. Defaults to 1.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.

The Economics module page introduces the module, and the sidebar lists all of its functions.

Share