Terms of Trade

Get the terms of trade of a variety of countries: the prices a country receives for its exports relative to the prices it pays for its imports, how many imports a unit of exports buys.

Rising terms of trade raise a country’s real income without any change in what it produces: an oil exporter gains when oil prices rise, an energy importer such as the euro area loses, as in 2022. They move the current account and, for commodity exporters, the exchange rate.

The formula is as follows:

\[\text{Terms of Trade} = \frac{\text{Export Price Index}}{\text{Import Price Index}} \cdot 100\]

The export and import price indices are those of get_export_price_index and get_import_price_index, monthly from each country’s official publisher: Eurostat for the euro area, the European Union and around 35 European countries (industrial producer prices on the non-domestic market over the import prices of industrial products, both 2021 = 100), the Bureau of Labor Statistics for the United States (the export and import price indices of all commodities, 2000 = 100; the last three years without a FRED API key) and the Bank of Japan for Japan (in yen, 2020 = 100). Both indices of a country have the same base year, so the terms of trade are 100 in that year; they cover goods (for Eurostat industrial goods), not services. The indices are not seasonally adjusted, which matters little for their ratio. Quarterly and yearly values are the ratio of the averages of the months, for complete periods only.

See definition: imf.org

Also known as: terms of trade index, TOT, export to import price ratio, net barter terms of trade.

Example · Euro Area, Germany, Spain, Japan · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_terms_of_trade:

from financetoolkit import Economics

economics = Economics(start_date='2021-01-01', end_date='2025-12-31')

economics.get_terms_of_trade(
    countries=['Euro Area', 'Germany', 'Spain', 'Japan'], period='yearly'
)

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How did the terms of trade of the euro area, Germany, Spain and Japan develop each year from 2021 to 2025?

Which returns:

Parameters

get_terms_of_trade accepts the following parameters.

ParameterTypeDescriptionExample
countrieslist[str] | str | NoneThe countries to include in the data. Defaults to None.["United States", "Germany"]
periodstr | NoneThe frequency of the data. Options are: “monthly” (monthly data), “quarterly” (quarterly data), “yearly” (yearly data). Defaults to None, which is quarterly when the Economics class was initialized with quarterly=True and monthly otherwise."weekly"
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. Defaults to None.4
transformstr | list[str] | NoneTime series steps applied in order, such as “sma:12” (moving average), “ema:12”, “std:12”, “zscore:60”, “percentile:120”, “yoy”, “pct_change:3,annualize:3”, “log”, “diff”, “cumsum” or “hp_trend” and “hp_cycle” (Hodrick-Prescott). They run before growth and the date range, on the history fetched with it: at least two years of monthly and three years of quarterly data before the start date, so a longer window needs an earlier start_date. Defaults to None.None
growthboolWhether to return the growth data or the actual data. Defaults to False.True
lagintThe number of periods to lag the data by. 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, which uses the rounding of the Economics class.2
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

Share