Get the Imports to GDP Ratio for a variety of countries over time from the Global Macro Database (GMDB). The Imports to GDP Ratio is the ratio of the total amount of goods and services produced in other countries that are bought by a country 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 (0.1213 for 12.13% 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: imports to GDP ratio.

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

Calculate the Imports to GDP in Python

The Imports to GDP is available in the Economics module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_imports_to_gdp_ratio as shown below.

from financetoolkit import Economics

economics = Economics(start_date='2010-01-01')

economics.get_imports_to_gdp_ratio(countries=['United States', 'Canada', 'Mexico'])

Which returns:

  United States Canada Mexico
2010 0.1588 0.3104 0.3026
2011 0.1728 0.3182 0.3172
2012 0.1704 0.3224 0.3272
2013 0.1639 0.319 0.3194
2014 0.164 0.3264 0.3264
2015 0.1528 0.3431 0.3625
2016 0.1456 0.3386 0.3887
2017 0.1495 0.3365 0.3944
2018 0.1516 0.3427 0.4117
2019 0.1447 0.3382 0.3893
2020 0.1301 0.3168 0.3762
2021 0.1442 0.3121 0.425
2022 0.1529 0.3371 0.4565
2023 0.1389 0.3382 0.3718
2024 0.1382 0.328 0.3491
2025 0.1352 0.3244 0.3336
2026 0.1313 0.3239 0.3253

Parameters

get_imports_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