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).
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).
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: debt-to-GDP ratio, fiscal sustainability.
Debt to GDP in Python
get_government_debt_to_gdp_ratio is part of the Economics module of the open-source Finance Toolkit. Install it 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')
economics.get_government_debt_to_gdp_ratio(countries=['Netherlands', 'Germany', 'China'])
Which returns:
| Netherlands | Germany | China | |
|---|---|---|---|
| 2015 | 0.638 | 0.7056 | 0.4149 |
| 2016 | 0.6088 | 0.6763 | 0.507 |
| 2017 | 0.5599 | 0.6395 | 0.5495 |
| 2018 | 0.5156 | 0.6073 | 0.5666 |
| 2019 | 0.4758 | 0.5856 | 0.604 |
| 2020 | 0.5334 | 0.6786 | 0.7016 |
| 2021 | 0.5044 | 0.6788 | 0.7185 |
| 2022 | 0.4835 | 0.6479 | 0.7739 |
| 2023 | 0.4502 | 0.6266 | 0.8438 |
| 2024 | 0.4426 | 0.6268 | 0.9012 |
| 2025 | 0.4511 | 0.621 | 0.9384 |
| 2026 | 0.4619 | 0.6095 | 0.9775 |
Parameters
get_government_debt_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.