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).

The ratio is the Global Macro Database’s own figure, published in percent and divided by 100 here.

The formula is as follows:

\[\text{Imports to GDP Ratio} = \text{Imports of Goods and Services} / \text{Nominal GDP}\]

Also known as: imports to GDP ratio.

Imports to GDP in Python or via the MCP

Install the Finance Toolkit 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', end_date="2025-12-31")

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

Or, after setting up the Finance Toolkit MCP, ask:

How did imports as a share of GDP compare in the United States, Canada and Mexico from 2010 to 2025?

Which returns:

  United States Canada Mexico
2010 0.1588 0.3104 0.3022
2011 0.1728 0.3182 0.3167
2012 0.1704 0.3224 0.3277
2013 0.1639 0.319 0.3195
2014 0.164 0.3264 0.3264
2015 0.1528 0.3431 0.3623
2016 0.1456 0.3386 0.3885
2017 0.1495 0.3365 0.3939
2018 0.1516 0.3427 0.411
2019 0.1447 0.3382 0.3894
2020 0.1302 0.3168 0.377
2021 0.1441 0.3107 0.4247
2022 0.1525 0.3323 0.4585
2023 0.1388 0.3323 0.3762
2024 0.1404 0.3265 0.3811
2025 0.138 0.3218 0.4025

Parameters

get_imports_to_gdp_ratio 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"]
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