Terms-of-trade #

This category group contains approximate dynamics of terms-of-trade. Currently, it is based on two main types. The first type, commodity-based terms of trade, uses commodity trade and price data alone, and can be consistently updated in real time at a daily frequency. The second type, mixed terms of trade, uses (a) low-frequency broad external trade data to capture medium-term dynamics and (b) daily commodity-based terms-of-trade to estimate recent and intermittent dynamics.

Generally, commodity terms-of-trade dynamics are ratios of approximate export and import price dynamics, whereby the latter are calculated on a daily basis based on concurrent vintages of commodity prices (in USD), commodity trade shares, and (as a non-commodity tradable USD goods’ price proxy) the U.S. core producer price index. There are two key differences between the JPMaQS commodities-based terms-of-trade series and those of other providers, beyond a set of more subtle methodological differences:

  1. First, JPMaQS series are point-in-time, always using the latest available commodity trade weights and producer prices.

  2. Second, while other externally available terms-of-trade proxy implicitly assumes stable non-commodity prices (effectively biasing terms-of-trade proxy in favor of commodity exporters), the JPMaQS proxy assumes that non-commodity export and import prices have grown in line with core PPI.

Commodity-based terms-of-trade dynamics #

Ticker : CTOT_NSA_PI / CTOT_NSA_P1M1ML12 / CTOT_NSA_P1W4WL1 / CTOT_NSA_P1M12ML1 / CTOT_NSA_P1M60ML1

Label : Commodities terms-of-trade, % change: since inception / latest month over a year ago / latest week over the previous 4 weeks / latest month over the previous 12 months / latest month over the previous 5 years

Definition : Commodities-based terms-of-trade, % change: since inception / latest month average (21 trading days) over the same month a year ago / latest week (5 trading days) over previous 4 weeks average / latest month average (21 trading days) over previous year average (261-trading days period) / latest month average (21 trading days) over previous 5 years average (1305-trading days period)

Notes :

  • Terms-of-trade dynamics are based on ratios of approximate export and import price dynamics, whereby the latter are calculated on a daily basis based on concurrent vintages of commodity prices (in USD), commodity trade shares, and (as a non-commodity tradable USD goods’ price proxy) the U.S. core producer price index. Export and import price dynamics are collected as ratios of latest price index divided by index at base period. For the exact calculation of commodity price-based export and import price indices see Appendix 1 .

  • The underlying vintages of all categories are based on commodity trade shares and related prices of liquidly-traded commodity contracts. Since the range of traded contracts has broadened overtime, so has the range of commodities that is used for the index. For example, for 1995, the number of usable contracts was 35. By 2005, it had grown to 44 and by 2015 to 55, which also marked the number contracts in use at the launch of this quantamental category in 2023. For details, see the bottom of Appendix 3 .

  • CTOT_NSA_PI is calculated based on the ratio of the export price index relative to inception divided by the import price index relative to inception, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100. Since the change to inception is always based on the latest concurrent vintage (point-in-time), daily changes can reflect actual terms-of-trade alterations as well as revisions. However, since the actual terms-of-trade changes are very dominant, this category can (and inevitably will) be used as a proxy of a daily terms-of-trade index. Strictly speaking, there is no such thing as a single point-in-time terms-of-trade series, but a vintage matrix, i.e. a collection of updating terms-of-trade series.

  • CTOT_NSA_P1M1ML12 is calculated based on the ratio of (i) the export price index average of the latest month relative to the export price index average of the same month a year ago divided by (ii) the import price index average of the latest month relative to the import price index average of the same month a year ago, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • CTOT_NSA_P1W4WL1 is calculated based on the ratio of (i) the export price index average of the latest week relative to the export price index average of the previous 4 weeks divided by (ii) the import price index average of the latest week relative to the import price index average of the previous 4 weeks, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • CTOT_NSA_P1M12ML1 is calculated based on the ratio of (i) the export price index average of the latest month relative to export price index average of the previous 12 months divided by (ii) the import price index average of the latest month relative to the import price index average of the previous 12 months, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • CTOT_NSA_P1M60ML1 is calculated based on the ratio of (i) the export price index average of the latest month relative to the export price index average of the previous 60 months divided by (ii) the import price index average of the latest month relative to the import price index average of the previous 60 months, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • Important : Percent changes of terms-of-trade are not symmetric but skewed to the high side. If only the export price index rises by 100%, the terms-of-trade change will be 100%. If only the import price index rises 100%, the terms of trade change will be 50%. If trading strategies and related research require symmetry, a logarithmic value of the implied change index or separate consideration of export and import price dynamics (see categories below) are more appropriate.

Mixed terms-of-trade dynamics #

Ticker : MTOT_NSA_PI / MTOT_NSA_P1M1ML12 / MTOT_NSA_P1W4WL1 / MTOT_NSA_P1M12ML1 / MTOT_NSA_P1M60ML1

Label : Mixed terms-of-trade, % change: since inception / latest month over a year ago / latest week over the previous 4 weeks / latest month over the previous 12 months / latest month over the previous 5 years

Definition : Combination of broad and commodity-based terms-of-trade, % change: since inception / latest month average (21 trading days) over the same month a year ago / latest week (5 trading days) over previous 4 weeks average / latest month average (21 trading days) over previous year average (261-trading days period) / latest month average (21 trading days) over previous 5 years average (1305-trading days period)

Notes :

  • Mixed terms-of-trade indicators are based on composite vintages. These vintages include actual broad export and import prices indices and, when these are not available, commodity-based indices. Since broad terms-of-trade are typically published at lower frequencies and with much longer lags, the commodity terms-of-trade are effectively used to predict and interpolate the broader series. For details on the methodology see Appendix 2 .

  • Broad export and import price indices are based on all traded items’ prices. Unlike commodity-based series, which are daily, the broad indices are released at annual or quarterly or monthly frequencies. For data reference see Appendix 4 .

  • Some countries (China, Hungary, Poland, Russia) do not publish broad export and import price indices, but only their percent changes over a year ago. In this case, we approximate the daily price levels of the first year in each vintage with the commodity indices and augment subsequently with the reported growth rates. This can result in artificial seasonality. Hence, short-term changes of these indicators should be regarded as rough proxies only.

  • Broad terms-of-trade can be subject to seasonality. Therefore, short-term changes of mixed terms-of-trade are subject to more noise around actual trends than medium-term changes.

  • MTOT_NSA_PI is calculated based on the ratio of the export price index relative to inception divided by import price index relative to inception, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100. Since the change to inception is always based on the latest concurrent vintage (point-in-time), daily changes can reflect actual terms-of-trade alterations as well as revisions. In particular, releases of broad terms-of-trades can significantly alter the series. Hence, unlike in the case of commodity-based indices, this % change since inception should not be used as a proxy of a daily index. In the case of mixed terms-of-trades, revisions do play a great role and hence historical dynamics should always consider vintages.

  • MTOT_NSA_P1M1ML12 is calculated based on the ratio of (i) the mixed export price index average of the latest month relative to the mixed export price index average of the same month a year ago divided by (ii) the mixed import price index average of the latest month relative to the mixed import price index average of the same month a year ago, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • MTOT_NSA_P1M12ML1 is calculated based on the ratio of (i) the mixed export price index average of the latest month relative to the mixed export price index average of the previous 12 months divided by (ii) the mixed import price index average of the latest month relative to the mixed import price index average of the previous 12 months, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • MTOT_NSA_P1M60ML1 is calculated based on the ratio of (i) the mixed export price index average of the latest month relative to the mixed export price index average of the previous 60 months divided by (ii) the mixed import price index average of the latest month relative to the mixed import price index average of the previous 60 months, based on the concurrent vintage. The percent change is this ratio minus 1 and times 100.

  • Important : Percent changes of mixed terms-of-trade are not symmetric but skewed to the high side. If only the export price index rises by 100%, the terms-of-trade change will be 100%. If only the import price index rises by 100%, the terms of trade change will be 50%. If trading strategies and related research require symmetry, a logarithmic value of the implied change index or separate consideration of export and import price dynamics (see categories below) are more appropriate.

Commodity-based export price dynamics #

Ticker : CXPI_NSA_PI / CXPI_NSA_P1M1ML12 / CXPI_NSA_P1W4WL1 / CXPI_NSA_P1M12ML1 / CXPI_NSA_P1M60ML1

Label : Commodities export price index, % change: since inception / latest month over a year ago / latest week over the previous 4 weeks / latest month over the previous 12 months / latest month over the previous 5 years

Definition : Commodities export price index, % change: since inception / latest month average (21 trading days) over the same month a year ago / atest week (5 trading days) over previous 4 weeks average / latest month average (21 trading days) over previous year average (261-trading days period) / latest month average (21 trading days) over previous 5 years average (1305-trading days period)

Notes :

  • All commodities export price index dynamics are based on concurrent vintages of commodity prices (in USD), commodity export trade shares, and (as a non-commodity tradable USD goods’ price proxy) the U.S. core producer price index.

  • The calculation of commodity price-based export and import price indices uses over 50 commodity categories. For details of the formulas used, see Appendix 1 and for details of the data used, see Appendix 3 .

Commodity-based import price dynamics #

Ticker : CMPI_NSA_PI / CMPI_NSA_P1M1ML12 / CMPI_NSA_P1W4WL1 / CMPI_NSA_P1M12ML1 / CMPI_NSA_P1M60ML1

Label : Commodities import price index, % change: since inception / latest month over a year ago / latest week over the previous 4 weeks / latest month over the previous 12 months / latest month over the previous 5 years

Definition : Commodities import price index, % change: since inception / latest month average (21 trading days) over the same month a year ago / latest week (5 trading days) over previous 4 weeks average / latest month average (21 trading days) over previous year average (261-trading days period) / latest month average (21 trading days) over previous 5 years average (1305-trading days period)

Notes :

  • All commodities import price index dynamics are based on concurrent vintages of commodity prices (in USD), commodity import trade shares, and (as a non-commodity tradable USD goods’ price proxy) the U.S. core producer price index.

  • The calculation of commodity price-based export and import price indices uses over 50 commodity categories. For details of the formulas used, see Appendix 1 and for details of the data used, see Appendix 3 .

Imports #

Only the standard Python data science packages and the specialized macrosynergy package are needed.

import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import math

import json
import yaml

import macrosynergy.management as msm
import macrosynergy.panel as msp
import macrosynergy.signal as mss
import macrosynergy.pnl as msn


from macrosynergy.download import JPMaQSDownload

from timeit import default_timer as timer
from datetime import timedelta, date, datetime

import warnings

warnings.simplefilter("ignore")

The JPMaQS indicators we consider are downloaded using the J.P. Morgan Dataquery API interface within the macrosynergy package. This is done by specifying ticker strings , formed by appending an indicator category code <category> to a currency area code <cross_section> . These constitute the main part of a full quantamental indicator ticker, taking the form DB(JPMAQS,<cross_section>_<category>,<info>) , where <info> denotes the time series of information for the given cross-section and category. The following types of information are available:

  • value giving the latest available values for the indicator

  • eop_lag referring to days elapsed since the end of the observation period

  • mop_lag referring to the number of days elapsed since the mean observation period

  • grade denoting a grade of the observation, giving a metric of real time information quality.

After instantiating the JPMaQSDownload class within the macrosynergy.download module, one can use the download(tickers,start_date,metrics) method to easily download the necessary data, where tickers is an array of ticker strings, start_date is the first collection date to be considered and metrics is an array comprising the times series information to be downloaded.

# Cross-sections of interest

cids_dmca = [
    "AUD",
    "CAD",
    "CHF",
    "EUR",
    "GBP",
    "JPY",
    "NOK",
    "NZD",
    "SEK",
    "USD",
]  # DM currency areas
cids_dmec = ["DEM", "ESP", "FRF", "ITL", "NLG"]  # DM euro area countries
cids_latm = ["BRL", "COP", "CLP", "MXN", "PEN"]  # Latam countries
cids_emea = ["CZK", "HUF", "ILS", "PLN", "RON", "RUB", "TRY", "ZAR"]  # EMEA countries
cids_emas = [
    "CNY",
    "HKD",
    "IDR",
    "INR",
    "KRW",
    "MYR",
    "PHP",
    "SGD",
    "THB",
    "TWD",
]  # EM Asia countries

cids_dm = cids_dmca + cids_dmec
cids_em = cids_latm + cids_emea + cids_emas

cids = sorted(cids_dm + cids_em)
exps = [
    "CXPI_NSA_PI",
    "CXPI_NSA_P1M1ML12",
    "CXPI_NSA_P1W4WL1",
    "CXPI_NSA_P1M12ML1",
    "CXPI_NSA_P1M60ML1",
]
imps = [
    "CMPI_NSA_PI",
    "CMPI_NSA_P1M1ML12",
    "CMPI_NSA_P1W4WL1",
    "CMPI_NSA_P1M12ML1",
    "CMPI_NSA_P1M60ML1",
]
ctots = [
    "CTOT_NSA_PI",
    "CTOT_NSA_P1M1ML12",
    "CTOT_NSA_P1W4WL1",
    "CTOT_NSA_P1M12ML1",
    "CTOT_NSA_P1M60ML1",
]
mtots = ["MTOT_NSA_PI", "MTOT_NSA_P1M1ML12", "MTOT_NSA_P1M12ML1", "MTOT_NSA_P1M60ML1"]
main = exps + imps + ctots + mtots
econ = [
    "REER_NSA_P1W4WL1",
    "REER_NSA_P1M12ML1",
    "REER_NSA_P1M60ML1",
]  # economic context
mark = ["FXXR_NSA", "FXXR_VT10", "FXXRHvGDRB_NSA"]  # market links

xcats = main + econ + mark
# Download series from J.P. Morgan DataQuery by tickers

start_date = "1990-01-01"
tickers = [cid + "_" + xcat for cid in cids for xcat in xcats]
print(f"Maximum number of tickers is {len(tickers)}")

# Retrieve credentials

client_id: str = os.getenv("DQ_CLIENT_ID")
client_secret: str = os.getenv("DQ_CLIENT_SECRET")

# Download from DataQuery

with JPMaQSDownload(client_id=client_id, client_secret=client_secret) as downloader:
    start = timer()
    df = downloader.download(
        tickers=tickers,
        start_date=start_date,
        show_progress=True,
        metrics=["value", "eop_lag", "mop_lag", "grading"],
        suppress_warning=True,
    )
    end = timer()

dfd = df

print("Download time from DQ: " + str(timedelta(seconds=end - start)))
Maximum number of tickers is 950
Downloading data from JPMaQS.
Timestamp UTC:  2024-02-23 12:27:28
Connection successful!
Requesting data: 100%|██████████| 190/190 [00:48<00:00,  3.93it/s]
Downloading data: 100%|██████████| 190/190 [01:05<00:00,  2.90it/s]
Some expressions are missing from the downloaded data. Check logger output for complete list.
536 out of 3800 expressions are missing. To download the catalogue of all available expressions and filter the unavailable expressions, set `get_catalogue=True` in the call to `JPMaQSDownload.download()`.
Some dates are missing from the downloaded data. 
3 out of 8912 dates are missing.
Download time from DQ: 0:02:10.857014

Availability #

cids_exp = cids  # cids expected in category panels
msm.missing_in_df(dfd, xcats=ctots + mtots, cids=cids_exp)
Missing xcats across df:  []
Missing cids for CTOT_NSA_P1M12ML1:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for CTOT_NSA_P1M1ML12:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for CTOT_NSA_P1M60ML1:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for CTOT_NSA_P1W4WL1:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for CTOT_NSA_PI:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for MTOT_NSA_P1M12ML1:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for MTOT_NSA_P1M1ML12:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for MTOT_NSA_P1M60ML1:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']
Missing cids for MTOT_NSA_PI:  ['DEM', 'ITL', 'FRF', 'ESP', 'NLG']

Real-time quantamental indicators of commodity-based terms-of-trade are available from 1995 for most of the countries, in line with commodity price availability. Exceptions are the Philippines and Russia (from 1996), Taiwan (1997), as well as the Eurozone and South Africa (2000).

Due to trade data availability, we use in-sample weights for the initial period when computing import and export price indices:

  • the Czech Republic, Great Britain, Hong Kong, and Norway use in-sample weights during the period 1995-01-01 / 1995-12-31

  • Poland, Romania and Thailand use in-sample weights during the period 1995-01-01 / 1996-12-31

  • Israel uses in-sample weights during the period 1995-01-01 / 1997-12-31

  • the Phillipines and Russia use in-sample weights during the period 1996-01-01 / 1998-12-31

  • Taiwan uses in-sample weights during the period 1997-01-01 / 1999-12-31

  • the Eurozone and South Africa use in-sample weights during the period 2000-01-01 / 2002-12-31

For the explanation of currency symbols, which are related to currency areas or countries for which categories are available, please view Appendix 6 .

xcatx = ctots
cidx = cids_exp

dfx = msm.reduce_df(dfd, xcats=xcatx, cids=cidx)
dfs = msm.check_startyears(
    dfx,
)
msm.visual_paneldates(dfs, size=(18, 6))

print("Last updated:", date.today())
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/253f4c8c21d90c08a309044379bfe89b4aa1b71b16fe4931ef4de2b4e5e44337.png
Last updated: 2024-02-23
xcatx = ctots
cidx = cids_exp

plot = msm.check_availability(
    dfd, xcats=xcatx, cids=cids_exp, start_size=(18, 6), start_years=False
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/628a78c487c5534f3ddd2dabfb35d5ef68e17bc3a1b446e995fe48dee8de0bd4.png

Real-time quantamental indicators of mixed terms-of-trade are mostly available from 2000, depending on the availability of the underlying data, i.e. both the commodity-based terms-of-trade and the broad import/export price indices published by each country’s statistical office.

Some countries have been publishing official terms-of-trade statistics since the 1990s or earlier:

  • Australia, Brazil, Canada, Switzerland, Colombia, Great Britain, South Korea, Mexico, Norway, New Zealand, Peru, Sweden, Singapore and the United States all have data from 1995 and are aligned with the corresponding CTOT indicator.

  • the Phillipines, the Eurozone, and South Africa have later starting dates and are also aligned with available CTOT dynamics.

  • the Czech Republic, Indonesia, India, Japan, Poland and Turkey have official import and export price series that are available from the late 1990s,

Others started later:

  • For China, Hungary, Israel, Malaysia, Romania, Russia and Thailand, official import and export price series have only been available from the 2000s.

  • Chile is a special case: due to methodology changes, price indices series are not available before 2003.

xcatx = mtots
cidx = cids_exp

dfx = msm.reduce_df(dfd, xcats=xcatx, cids=cidx)
dfs = msm.check_startyears(
    dfx,
)
msm.visual_paneldates(dfs, size=(18, 6))

print("Last updated:", date.today())
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/8039b62e65589cb3745ffd34ef3fc89ae6ec24f757e1a947aaaf7667522a0010.png
Last updated: 2024-02-23
xcatx = mtots
cidx = cids_exp

plot = msm.check_availability(
    dfd, xcats=xcatx, cids=cids_exp, start_size=(18, 6), start_years=False
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/d7aeb03b77fa8f7e39a7e95fe2a711a7a93c91c639f25cbe536e20d4871eda8c.png

The quality of the grading is mostly a function of the trade flow data. Broad terms-of-trade information have not often been stored as vintages and is hard to procure in its original form thus far.

xcatx = ctots + mtots
cidx = cids_exp

plot = msp.heatmap_grades(
    dfd,
    xcats=xcatx,
    cids=cidx,
    size=(18, 6),
    title=f"Average vintage grades from {start_date} onwards",
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/c348c36a96f3cfc3ec3f34b2b749b3978c1ceb90f0c23207adf50cbf63d08037.png
xcatx = ["CTOT_NSA_P1M1ML12"]
cidx = cids_exp

msp.view_ranges(
    dfd,
    xcats=xcatx,
    cids=cidx,
    val="eop_lag",
    title="End of observation period lags (ranges of time elapsed since end of observation period in days)",
    start="1995-01-01",
    kind="box",
    size=(16, 4),
)

msp.view_ranges(
    dfd,
    xcats=xcatx,
    cids=cidx,
    val="mop_lag",
    title="End of observation period lags (ranges of time elapsed since end of observation period in days)",
    start="1995-01-01",
    kind="box",
    size=(16, 4),
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/1d0f12d9d4e65c052dff536a1adc2e44671a9355a36639261e1aa67c38dc4af3.png https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/dde638880d70cd3da3b58c23be80fbfb3ab9000d603be819bf325a96be9b74c5.png

History #

Terms-of-trade cumulative change #

The cumulative change series conceptually measures, on each date, the % increase in the export-import ratio relative to inception. For most countries, the inception date is February 1st, 1995. For most countries, the range has been contained in a range of -40% and +80% over the past 28 years. The long-term cumulative changes have been very different across currency areas.

Note that since the index is based on a price ratio, the cumulative change series is skewed to the high side. For example, if export prices rise 3 times as much as import prices, it would reach 300%. But if import prices rise 3 times as much as export prices, it would reach 33%. For trading signals, it may be better to create a log ratio series based on this series to ensure balanced signals from positive and negative terms-of-trade changes.

There can be significant differences between commodity and mixed terms of trade, particularly for economies where commodities have little weight. Also some countries, particularly the Phillipines, show pronounced seasonality in mixed terms-of-trade, as non-commodity trade prices can be subject to greater seasonal fluctuations.

xcatx = ["CTOT_NSA_PI", "MTOT_NSA_PI"]
cidx = cids_exp

msp.view_timelines(
    dfd,
    xcats=xcatx,
    cids=cidx,
    start="1995-01-01",
    title="Commodities-based (blue) versus mixed (orange) terms-of-trade, % change since inception, since 1995",
    label_adj=0.075,
    title_fontsize=27,
    legend_fontsize=17,
    xcat_labels=["Commodity-based", "Mixed"],
    ncol=5,
    same_y=False,
    size=(12, 7),
    aspect=1.7,
    all_xticks=True,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/d597dd24271e56708ed2f57e4fe12977f82d5d387bb841abddbb80513145eaad.png

Relative commodities-based export and import price ratios change if the weight of commodities of the individual price ratios are very different and in time when commodity markets move significantly.

xcatx = ["CXPI_NSA_PI", "CMPI_NSA_PI"]
cidx = cids_exp

msp.view_timelines(
    dfd,
    xcats=xcatx,
    cids=cidx,
    start="1995-01-01",
    title="Commodities-based export and import prices, indices",
    xcat_labels=["Export price index", "Import price index"],
    title_fontsize=27,
    legend_fontsize=17,
    ncol=4,
    same_y=False,
    size=(12, 7),
    aspect=1.7,
    all_xticks=True,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/e10c07a0255ee1be0822cefa0f2fcce3936534e9878326f1a3863b99dd3ee891.png

Short-term terms-of-trade dynamics #

Short-term variations in terms of trade, such as latest week over previous four weeks, display very different variability, with commodity exporters and some countries with heavy reliance on commodity imports posting the greatest variation.

xcatx = ["CTOT_NSA_P1W4WL1"]
cidx = cids_exp

msp.view_ranges(
    dfd,
    xcats=xcatx,
    cids=cidx,
    sort_cids_by="mean",
    start="1995-01-01",
    title="Means and standard deviations of short-term terms-of-trade dynamics, since 1995",
    xcat_labels=["% latest week over 4 weeks ago"],
    kind="bar",
    size=(16, 8),
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/0b1bdc72ddf0756cdfaf1adedc37c8b943539a5a95077e7e7f1ee59fa74e7076.png

For some cross-sections, variation has been uneven across the years. This reflects mainly changes in the trade structure, such as the growing or declining importance of commodities. In some cases, the broadening of tradable commodity contracts has also affected variations.

xcatx = ["CTOT_NSA_P1W4WL1"]
cidx = cids_exp

msp.view_timelines(
    dfd,
    xcats=xcatx,
    cids=cidx,
    start="1995-01-01",
    title="Commodity-based terms-of-trade, % increase of the last week vs the previous 4 weeks",
    title_fontsize=27,
    ncol=4,
    same_y=False,
    size=(12, 7),
    aspect=1.7,
    all_xticks=True,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/4aed0776aea3a677c02b807442cf7037e918638dddde90f329c496644b74cb7e.png

Correlation of terms of trade has been groupwise positive and negative, mostly depending on whether a currency area is a net commodity exporter or importer.

xcatx = "CTOT_NSA_P1W4WL1"
cidx = cids_exp

msp.correl_matrix(
    dfd,
    xcats=xcatx,
    cids=cidx,
    title="Cross-sectional correlations of short-term commodity-based terms-of-trade, since 2000",
    size=(20, 14),
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/9a07428b6a7457b38b9c26521c9049b41a51afec64a1b53e1570e8beb0d7fe6f.png

Medium-term terms-of-trade dynamics #

The medium-term terms-of-trade changes have displayed pronounced cycles in past decades, providing impetus for growth and inflation divergences across countries.

xcatx = ["CTOT_NSA_P1M1ML12", "CTOT_NSA_P1M12ML1"]
cidx = cids_exp

msp.view_timelines(
    dfd,
    xcats=xcatx,
    cids=cidx,
    start="1995-01-01",
    title="Commodities-based terms-of-trade, % last month versus a year ago (blue) and 1 year average (orange)",
    xcat_labels=[
        "% last month, over a year ago",
        "% last month, versus 1 year-average",
    ],
    title_fontsize=27,
    legend_fontsize=17,
    ncol=4,
    same_y=False,
    size=(12, 7),
    aspect=1.7,
    all_xticks=True,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/83fa60d9af569de7098c2d5ea0236ecddf2c533b681c9fda5ad66858f72498ad.png

While the use of mixed terms of trade is more inclusive, it can also add volatility.

xcatx = ["CTOT_NSA_P1M1ML12", "MTOT_NSA_P1M1ML12"]
cidx = cids_exp

msp.view_timelines(
    dfd,
    xcats=xcatx,
    cids=cidx,
    start="1995-01-01",
    title="Commodities-based and mixed terms-of-trade, % over a year ago",
    xcat_labels=["Commodities-based", "Mixed"],
    title_fontsize=27,
    legend_fontsize=17,
    ncol=4,
    same_y=False,
    size=(12, 7),
    aspect=1.7,
    all_xticks=True,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/4c2b684a925d55acbf1c2b63ed37d5b6d521ad58690217cb69da645a4ee091b3.png

Long-term terms-of-trade dynamics #

Estimated terms-of-trade changes over 5-year averages are, by themselves, indicative of investment and medium-term economic growth conditions. However,to assess the actual impact on local economic conditions it would be best to multiply this indicator with the quantamental “openess indicator” on JPMaQS, as terms of trade usually have a greater impact on countries with a large exteranl trade share.

There is a trade-off between using commodity and mixed terms-of-trade for long-term terms-of-trade dynamics. The mixed terms of trade are naturally more inclusive and representative. The drawback is the shorter history and poor data quality in some countries, particularly those that do not publish actual price index levels. Also, seasonality adds additional volatility.

xcatx = ["CTOT_NSA_P1M60ML1", "MTOT_NSA_P1M60ML1"]
msp.view_timelines(
    dfd,
    xcats=xcatx,
    cids=cidx,
    start="2000-01-01",
    title="Commodity-based and mixed terms-of-trade, % increase of the last month vs the last 5 years",
    xcat_labels=["Commodity-based", "Mixed"],
    title_fontsize=27,
    legend_fontsize=17,
    ncol=4,
    same_y=False,
    size=(12, 7),
    aspect=1.7,
    all_xticks=True,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/4d4575c85b67998a6f5b2af39ff7566343a94bb30a6bd900441a418448cf3346.png

Importance #

Empirical clues #

Terms-of-trade changes, at all frequencies, have been positively correlated with concurrent real-effective exchange rate changes. Countries which see their export prices rising against their import prices tend to experience appreciation. From a currency trading perspective, this suggests that both changes have to be viewed together to estimate the impact of global market shocks on subsequent FX returns.

dfb = dfd[dfd["xcat"].isin(["FXTARGETED_NSA", "FXUNTRADABLE_NSA"])].loc[
    :, ["cid", "xcat", "real_date", "value"]
]
dfba = (
    dfb.groupby(["cid", "real_date"])
    .aggregate(value=pd.NamedAgg(column="value", aggfunc="max"))
    .reset_index()
)
dfba["xcat"] = "FXBLACK"
fxblack = msp.make_blacklist(dfba, "FXBLACK")
cr = msp.CategoryRelations(
    dfd,
    xcats=["CTOT_NSA_P1M12ML1", "REER_NSA_P1M12ML1"],
    cids=list(set(cids) - set(["DEM", "ESP", "FRF", "HKD", "ITL", "NLG"])),
    freq="A",
    lag=0,
    xcat_aggs=["last", "last"],
    start="2000-01-01",
)

cr.reg_scatter(
    title="Terms-of-trade and real trade-weighted exchange rate dynamics, % over a year ago, annual frequency",
    labels=True,
    coef_box="upper left",
    xlab="Commodities-based terms-of-trade change, % over a year ago, annual average",
    ylab="Real effective appreciation, % over a year ago, annual average",
    prob_est="map",
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/95afebf6fe20917b47dfc97150fbd36c2222b831e4c2a055e1f039b99942906e.png
cr = msp.CategoryRelations(
    dfd,
    xcats=["CTOT_NSA_P1M12ML1", "REER_NSA_P1M12ML1"],
    cids=list(set(cids) - set(["DEM", "ESP", "FRF", "HKD", "ITL", "NLG"])),
    freq="Q",
    lag=0,
    xcat_aggs=["last", "last"],
    start="2000-01-01",
)

cr.reg_scatter(
    title="Terms-of-trade and real trade-weighted exchange rate dynamics, % over a year ago, quarterly frequency",
    labels=False,
    coef_box="upper left",
    xlab="Commodities-based terms-of-trade change, % over a year ago, quarterly average",
    ylab="Real effective appreciation, % over a year ago, quarterly average",
    prob_est="map",
    separator=2010,
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/724ecd56d8956355dd29c26715e1319ee3663b2bd16971782181479a55a04472.png

Indeed, there is evidence that in the developed world, the excess commodity terms of trade changes, controlling for real-effective exchange rate changes, is a far more promising (and statistically significant) predictor of hedged FX forward returns than terms of trade changes on its own.

xcatx = ["CTOT_NSA_P1W4WL1", "FXXRHvGDRB_NSA"]
cidx = cids_dmca

cr = msp.CategoryRelations(
    dfd,
    xcats=xcatx,
    cids=list(set(cidx) - set(["USD"])),
    freq="M",
    lag=1,
    xcat_aggs=["last", "sum"],
    start="2000-01-01",
    # xcat_trims=[60, 60],
    blacklist=fxblack,
)

cr.reg_scatter(
    title="Short-term commodity terms of trade changes and next-month cumulative hedged FX returns, developed markets, since 2000",
    labels=False,
    coef_box="upper left",
    xlab="Commodity terms-of-trade change, % latest week over the previous 4 weeks",
    ylab="Next month total FX forward return (hedged against global directional risk)",
    prob_est="map",
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/2fa5bf196a0e185bd0c3af43ce781b19e55fa729eb0a7de91a6af20afb8d1470.png
cidx = cids_dmca
tf = "_P1W4WL1"
dfa = msp.panel_calculator(
    dfd, calcs=[f"TR{tf} = CTOT_NSA{tf} - REER_NSA{tf}"], cids=cidx, start="2000-01-01"
)
dfx = msm.update_df(dfd, dfa)


cr = msp.CategoryRelations(
    dfx,
    xcats=[f"TR{tf}", "FXXRHvGDRB_NSA"],
    cids=list(set(cidx) - set(["USD"])),
    freq="M",
    lag=1,
    xcat_aggs=["last", "sum"],
    start="2000-01-01",
    blacklist=fxblack,
)

cr.reg_scatter(
    title="Short-term CToT - REER changes and next-month cumulative hedged FX returns, developed markets, since 2000",
    labels=False,
    coef_box="upper left",
    xlab="Commodities-based terms-of-trade change minus real appreciations, % last week over previous 4 weeks",
    ylab="Next-month total FX forward return (hedged against global directional risk)",
    prob_est="map",
)
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/cb65a089173b5763e1f32c07bf5d86495c0717cc79f2b7bce8d7125e6918dfad.png

A similar observation can be made for the prediction of the direction of hedged FX forward returns. By controlling for changes in the real effective exchange rate, the accuracies increase in the cross-sections: Canada, Switzerland, Great Britain and Norway. This, in turn, leads to an increase in accuracy and balanced accuracy over the panel.

Moreover, the probabilities of significance in positive (pearson and kendall) correlations between the respective predictor and the subsequent hedged FX returns are clearly boosted across the panel and indeed a number of cross-sections when using excess commodity terms of trade changes to explain the return variation. This is seen most clearly for Great Britain, Switzerland and Canada.

sr = mss.SignalReturnRelations(
    dfd,
    "FXXRHvGDRB_NSA",
    "CTOT_NSA_P1W4WL1",
    cids=list(set(cidx) - {"NLG", "ESP", "DEM", "ITL", "FRF", "USD"}),
    blacklist=fxblack,
)
sr.accuracy_bars()
sr.correlation_bars()
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/0c0f8c4c63f7447f4476d9207f8c4b097537dc442391afa0ded5156d2034452e.png https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/b62b1b168f596c0293b1d786ce57792c869995cbfb60610983b34699ac9baec8.png
xcatx = ["CTOT_NSA_P1W4WL1", "FXXRHvGDRB_NSA"]
cidx = list(set(cids_dmca) - set(["USD"]))

sr = mss.SignalReturnRelations(
    dfx, "FXXRHvGDRB_NSA", "TR_P1W4WL1", cids=cidx, blacklist=fxblack
)
sr.accuracy_bars()
sr.correlation_bars()
https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/aa15c08ff2a54544a1699d4c8b5dc12026e6335e9c80cd33ea33b6e84ad66c4b.png https://macrosynergy.com/notebooks.build/themes/financial-conditions/_images/1a9f4cc0b1396733f8b2360a6e0682f43683dcd5ae8413c35254d5cf259737c4.png

Appendices #

Appendix 1: How commodity-based price indices are computed #

Terms-of-trade is the ratio of a country’s export price index to its import price index. Conceptually, it measures the quantity of an abstract good a country can import for a unit of abstract good that it exports.

Conventionally, it is the weighted average of export prices (export price index, XPI) divided by the weighted average of import prices (import price index, MPI). All prices shall be quoted in USD. However, the ratio is a unit-less quantity and it is tracked as an index.

\[ ToT_t= \frac{XPI_t}{MPI_t} \]

Both numerator and denominator of a terms-of-trade index in JPMaQS are calculated are calculated in the form of Laspeyres indices. This means that the export and import quantities of the index are fixed to a base period. The importance of a traded good’s price in the export or import price index depends on its traded quantity in a base period and the price itself. The generic for the export price index, for example, looks as follows

\[ XPI_t= \frac{ \sum_{i} P[x]_{t,i}∙Q[x]_{0,i} }{ \sum_{i} P[x]_{0,i}∙Q[x]_{0,i} } \]

where \(Q[x]_{t, i}\) denote the \(i^{th}\) good’s export quantity in physical units in period t, and \(P[x]_{t, i}\) I refers to the unit price of export good \(i\) in period t.

Period \(t=0\) here refers to a base period for the calculation of the index.

Alternatively, we can express the export price index is as a weighted sum of price ratios: $ \( XPI_t= \sum_{i} \frac{P[x]_{t,i}}{P[x]_{0,i}} \cdot \omega[x]_{0, i} \) $

where the weight of each good is its share in total export value in the base period:

\[ \omega[x]_{0, i}= \frac{ P[x]_{t,i}∙Q[x]_{0,i} }{ \sum_{j} P[x]_{0,j}∙Q[x]_{0,j} } \]

where the denominator is the sum over the export values of all goods (indexed by j).

These weights can be derived from annual trade value statistics.

The implementation of approximate commodity terms-of-trade in JPMaQS required three practical modifications of these general formulas.

  1. First, only a subset of exports and imports can be associated to daily proxy prices, these typically being commodity goods with global or regional tracked contracts. This means we need to distinguish between commodities (c) and non-commodities (nc). The set of goods with available daily price is referred to as “commodities”, of size \(N_c\) and indexed with \(j\) . The remaining set of goods is referred to as “non-commodities”, of size \(N_{nc}\) and indexed with \(k\) . They clearly sum up to \(N = N_c + N_{nc}\) different goods.

\[ XPI_t= \sum_{j}^{N_c}{ \frac{P[x_c]_{t,j}}{P[x_c]_{0,j}} \cdot \omega[x_c]_{0, j} } + \sum_{k}^{N_{nc}}{ \frac{P[x_{nc}]_{t,k}}{P[x_{nc}]_{0,k}} \cdot \omega[x_{nc}]_{0, k} } \]

with the export trade share for a general good \(i\)

\[ \omega[x_c]_{0, i} = \frac{P[x_c]_{0,i}∙Q[x_c]_{0,i}}{\sum_{j}^{N_c} P[x_c]_{0,j}∙Q[x_c]_{0,j} + \sum_{k}^{N_{nc}} P[x_c]_{0,k}∙Q[x_c]_{0,k}} \]

Typically, we have no information on non-commodity prices or even some commodities that are not quoted in markets. This means that the price index equation simplifies:

\[ XPI_t= \sum_{i}^{N_c}{ \frac{P[x_c]_{t,i}}{P[x_c]_{0,i}} \cdot \omega[x_c]_{0, i} } + ( \frac{P_t}{P_0} \cdot \sum_{j}^{N_{nc}}{\omega[x_{nc}]_j}) \]

where \(P_{t}\) is a generic tradable goods price index that represents international non-commodity goods price inflation. JPMaQS uses the U.S. core PPI for this purpose.

  1. Representative export and import weights change overtime and, hence, weights need to be updated. We do so by first calculating monthly price indices and then chaining them. We use a double time index \((m, d)\) instead of \(t\) , where the first element represent the month and the second is the specific trading day. \(ld\) is the last trading day available in that month.

The monthly price indices are calculated in the following way, so that it has a base period value of 1 at the beginning of each period \(m\) .

\[ XPI_{m, d}= \sum_{j}^{N_c}{ \frac{P[x_c]_{m,d,j}}{P[x_c]_{m-1,ld,j}} \cdot \omega[x_c]_{m,j} } + ( \frac{P_{m,d}}{P_{m-1, ld}} \cdot \sum_{k}^{N_{nc}}{\omega[x_{nc}]_{m, k}}) \]

where \(\omega[x_c]_{m,j}\) refers to the weight of good j estimated for month \(m\) based on the information set at the end of month \(m-1\) .

To concatenate the monthly price indices, we simply need to multiply the latest month’s index values with the product of all previous months’ endpoints:

\[ XPI_{t} = XPI_{m, d} \cdot \prod_{\tau=m_0}^{m-1} XPI_{\tau,ld} \]
  1. Global core producer prices are not available on daily basis and they may not even be available for the concurrent month at all. Hence the daily produce price needs to be interpolated and potentially estimated.

When the PPI data has been published for a given month \(m\) , then we can interpolate this price growth over the month. $ \( \frac{P_{m, d}}{P_{m, 0}} = (1+\pi_{m})^{d / D_m} \) $

For the most recent months in each vintage, it is possible that the PPI data has not been published yet so we need to estimate this quantity daily: $ \( \frac{P_{m, d}}{P_{m, 0}} = (1+ Est[\pi_{m}])^{d / D_m} \) $

where \(D_m\) is the number of trading days in month \(m\) .

Appendix 2: Combining broad and commodity-based terms of trade to mixed terms of trade #

Mixed terms of trade combine broad terms of trade data, conceptually encompassing all foreign trade items, and commodity-based terms of trade data.

Broad external trade flows and corresponding price indices are being published by most countries, albeit with significant lags and typically at monthly or quarterly frequency. Compared with daily real-time commodity-based data they often look out-of-date and are therefore neglected by market participants. The mixed terms of trade concept is based on export and import price indices that use broad terms of trade for medium-term changes and commodities-based terms of trade for daily interpolation and prediction to the latest day.

Technically speaking we calculate first mixed export and import price indices, based on these two types of constituent price indices ( BXPI and BMPI ):

  • The first type uses official export and import price indices as released by national statistics offices of similar agencies, which we call broad price indices ( BXPI and BMPI ). They are based on the prices of all foreign trade items. These typically have monthly or quarterly frequency and can have a few months lag between release and the observation period.

  •          The second type are the JPMaQS commodity terms of trade (**CXPI**, **CMPI**) using primary commodity trade and related market prices only. These are available daily at the beginning of the next trading day.
    

In the first stage of calculation, the two types of price indices are computed separately in form of vintages for equal history with an index starting point of 1 for the first day. Naturally index valuse are strictly positive. The second stage the two types are combined such that the broad lower-frequency index, anchors the long-term average of the vintages and the commodity price index is used for interpolation and predictions.

For the case of export price and monthly broad terms of trade the combined value is:

\[ MXPI_{t} = CXPI_{t} \cdot \frac{BXPI_{m}}{CXPI_{m}} \]

where t is a trading day and m the average of the concurrent or latest available month. Lower frequency values are considered averages because the use of period averages is a common method for measuring these price indices (at least conceptually). If t is a day of month m this formula implies interpolation. If t is a day after (the latest available) month m the formula implies prediction.

A few countries (China, Hungary, Poland, Russia) do not release their broad import/export prices as index. They only inform about a percentage change over a year ago. We refer to this format as BXPIPCT and BMPIPCT . This means that index levels must be estimated based on these changes and available levels of the commodity export or import index.

The first step is to use the commodity price index, as low-frequency averages, to estimate the broad price index levels in the first year. For the export price index and assuming a monthly broad index frequency this applies the following formula:

\[ BXPI_m = CXPI_m \text{ for } m <13 \]

The second step is to use the offically provided broad index change to calculate all subsequent broad index levels:

\[ BXPI_m = BXPI_{m -12} \cdot BXPIPCT_{m} \]

Appendix 3: Commodity data inputs #

The commodity export and import values for all countries are taken from the United Nations Comtrade database. The frequency of the data has been monthly since 2010. Prior to 2010 the frequency was annual. Trade shares of individual commodities are export/import values divided by the corresponding period’s aggregate import and export values, which come from a variety of sources. Therefore, since 2010 trade shares have been updated monthly with the appropriate publication lag. Taiwan only provides annual releases of commodity export and import values and, hence, trade shares are updated less frequently.

Shares are computed based on a rolling window of three years of trade values, based on the concurrent vintage.

We use a comprehensive set of commodities and corresponding commodity prices to approximate as best as we can the daily move of the true (unobserved) terms-of-trade. Commodity-based and mixed terms-of-trade indicators use 35 commodities at the start in 1995, growing up to 44 in 2005 and reaching 55 from 2010 afterwards.

We can break them down into sub-categories, explicitly mentioning the first year they are available:

  • Energy:

    • Coal:

      • NYMEX Coal (pre 2006)

      • ICE Coal Richard Bay (2006)

      • ICE Coal Rotterdam (2006)

      • ICE Newcastle Coal (2006)

    • Crude oil:

      • Brent Forties Oseberg FOB (1970)

      • NYMEX WTI light crude (1983)

    • Ethanol: CBOT Ethanol (2006)

    • Gasoline: NYMEX RBOB Gasoline (2005)

    • Liquefied natural gas: Liquid Natural Gas FOB Asia (2010)

    • Natural gas:

      • NYMEX natural gas Henry Hub (1995)

      • TTF base load (2010)

    • Propane: Propane Spot FOB Mont Belvieu (1992)

  • Industrial Metals:

    • Aluminium: London Metal Exchange aluminium (1995)

    • Cobalt: London Metal Exchange cobalt (2010)

    • Copper: COMEX copper (1989)

    • Lead: London Metal Exchange Lead (1995)

    • Iron ore:

      • HWWI Iron Ore & Steel Scrap index (weekly, 2001-2007)

      • Steel Home Iron Ore FE63.5% CIF (2007)

    • Molybdenum: Molybdenum MO3 CIF (1993)

    • Nickel: London Metal Exchange Nickel (1995)

    • Rhodium: Rhodium spot for North West Europe CIF (1993)

    • Tin: London Metal Exchange Tin (1995)

    • Zinc: London Metal Exchange Zinc (1995)

  • Precious metals

    • Gold: COMEX gold 100 Ounce (1992)

    • Palladium: NYMEX palladium (1995)

    • Platinum: NYMEX platinum (1995)

    • Silver: COMEX silver 5000 Ounce (1992)

  • Softs:

    • Cocoa:

      • CSCE Cocoa (1979)

      • LIFFE Cocoa (1979)

    • Coffee: NYBOT / ICE coffee ‘C’ Arabica (1995)

    • Cotton: NYBOT / ICE cotton #2 (1995)

    • Dry whey: CME dry whey (2007)

    • Lumber: Chicago Mercantile Exchange random length lumber (1995)

    • Milk: Chicago Mercantile Exchange milk class IV (2000)

    • Milk powder (skimmed):

      • EU Agricultural Market Skimmed Milk Powder (weekly, 2001-2010)

      • Global Dairy Trade Milk powder skim (2010)

    • Milk powder (whole):

      • EU Agricultural Market Whole Milk Powder (weekly, 2001-2008)

      • Global Dairy Trade Milk powder whole (2008)

    • Orange juice concentrate: NYBOT / NYCE FCOJ frozen orange juice concentrate (1995)

    • Refined sugar: LIFFE White sugar (1989)

    • Sugar:

      • NYBOT / ICE raw cane sugar #11 (1995)

      • NYBOT / ICE raw cane sugar #16 (2008)

    • Tea: Tea Best Pekoe Fannings 1 Kenya (1993)

  • Grains:

    • Barley: Barley Minneapolis (1995)

    • Corn:

      • Chicago Board of Trade corn composite (1995)

      • MATIF Corn (2002)

    • Oats: Chicago Board of Trade oats (2006)

    • Soy beans: Chicago Board of Trade soybeans composite (1995)

    • Soymeal: Chicago Board of Trade soybean meal (2006)

    • Soybean oil: Chicago Board of Trade soybean oil (1975)

    • Rapeseed oil: Rapeseed Oil Dutch FOB North West Europe

    • Palm oil: Malaysian Palm Oil Crude CIF Rotterdam (1995)

    • Rice: White Rice 100pct FOB Bangkok (2008)

  • Wheat:

    • Chicago Board of Trade wheat composite (1995)

    • LIFFE Wheat (1989)

    • MATIF Wheat (1998)

  • Livestock:

    • Live cattle: Chicago Mercantile Exchange (1995)

    • Cattle feeder: Chicago Mercantile Exchange Feeder Cattle Composite (1978)

    • Hogs: Chicago Mercantile Exchange Lean Hogs Composite (1995)

    • Salmon: Fish pool salmon (2008)

    • Fish meal: Fish meal 65% Peru CIF Germany (1999)

  • Chemicals:

    • Urea:

      • Urea FOB Arab Gulf (2009)

      • Urea FOB US Gulf (2009)

      • Urea ammonium nitrate (UAN):

      • Urea Ammonium Nitrate 30% FOT France (2008)

      • Urea Ammonium Nitrate 30% FOT New Orleans (2008)

      • Diammonium Phosphate (DAP): Diammonium Phosphate CF New Orleans (2002)

      • Rubber: RSS3 smoked rubber sheets (1992)

Most of the commodity prices approximate well the trade activity happening over different geographies, so we associate the cross-section identifiers to these commodity prices.

In certain regions, we identify better price proxies for specific commodities, which allows us to improve the terms-of-trade estimation on a daily basis: coal, crude oil, natural gas, cocoa, sugar, corn, wheat, urea, and urea ammonium nitrate.

Hide code cell content
comm_cid_map = {
    "Coal": {
        "default": "ICE Richard Bay",
        "Asia": "ICE Newcastle",
        "Europe": "ICE Rotterdam",
    },
    "Crude oil": {
        "default": "ICE Brent",
        "North America": "NYMEX WTI",
    },
    "Ethanol": {"default": "CBOT"},
    "Gasoline": {"default": "NYMEX"},
    "Propane": {"default": "Spot FOB Mont Belvieu"},
    "LNG": {"default": "Liquid Natural Gas FOB Asia"},
    "Natural gas": {"default": "NYMEX Henry Hub", "Europe": "TTF base load"},
    "Cocoa": {"default": "CSCE", "Europe": "LIFFE"},
    "Coffee": {"default": "NYBOT ICE"},
    "Orange juice": {"default": "NYBOT NYCE"},
    "Tea": {"default": "Best Pekoe Fannings"},
    "Milk": {"default": "CME"},
    "Milk powder s.": {"default": "Global dairy trade"},
    "Milk powder w.": {"default": "Global dairy trade"},
    "Dry whey": {"default": "CME"},
    "Sugar": {
        "default": "NYBOT ICE n11",
        "North America": "NYBOT ICE n16",
    },
    "White sugar": {"default": "SGW"},
    "Barley": {"default": "BAR"},
    "Corn": {"default": "CBOT", "Europe": "MATIF"},
    "Oats": {"default": "CBOT"},
    "Palm oil": {"default": "CBOT"},
    "Rapseed oil": {"default": "Dutch FOB North west Europe"},
    "Rice": {"default": "White Rice 100pct FOB Bangkok"},
    "Soybean meal": {"default": "CBOT"},
    "Soybean oil": {"default": "CBOT"},
    "Soybeans": {"default": "CBOT"},
    "Wheat": {
        "default": "CBOT",
        "UK": "LIFFE",
        "Europe": "MATIF (ex-GBP)",
    },
    "Cotton": {"default": "NYBOT ICE"},
    "Lumber": {"default": "CME"},
    "Urea": {"default": "FOB US Gulf", "Asia": "FOB Arab Gulf"},
    "UAN": {"default": "32% FOB New Orleans", "Europe": "30% FOT France"},
    "DAP": {"default": "CF New Orleans"},
    "Rubber": {"default": "RSS3 smoked sheets"},
    "Salmon": {"default": "Fishpool"},
    "Fishmeal": {"default": "65% Peru CIF Germany"},
    "Cattle": {"default": "CME"},
    "Feeder": {"default": "CME"},
    "Hogs": {"default": "CME"},
    "Aluminium": {"default": "LME"},
    "Cobalt": {"default": "LME"},
    "Copper": {"default": "COMEX"},
    "Iron ore": {"default": "Steel home"},
    "Lead": {"default": "LME"},
    "Molybdenum": {"default": "MO3 CIF"},
    "Nickel": {"default": "LME"},
    "Rhodium": {"default": "spot NWE CIF"},
    "Tin": {"default": "LME"},
    "Zinc": {"default": "LME"},
    "Gold": {"default": "COMEX"},
    "Platinum": {"default": "NYMEX"},
    "Silver": {"default": "NYMEX"},
    "Palladium": {"default": "PAL"},
}
commodity_geo_map = pd.DataFrame(comm_cid_map).fillna(value="").T
display(commodity_geo_map)
default Asia Europe North America UK
Coal ICE Richard Bay ICE Newcastle ICE Rotterdam
Crude oil ICE Brent NYMEX WTI
Ethanol CBOT
Gasoline NYMEX
Propane Spot FOB Mont Belvieu
LNG Liquid Natural Gas FOB Asia
Natural gas NYMEX Henry Hub TTF base load
Cocoa CSCE LIFFE
Coffee NYBOT ICE
Orange juice NYBOT NYCE
Tea Best Pekoe Fannings
Milk CME
Milk powder s. Global dairy trade
Milk powder w. Global dairy trade
Dry whey CME
Sugar NYBOT ICE n11 NYBOT ICE n16
White sugar SGW
Barley BAR
Corn CBOT MATIF
Oats CBOT
Palm oil CBOT
Rapseed oil Dutch FOB North west Europe
Rice White Rice 100pct FOB Bangkok
Soybean meal CBOT
Soybean oil CBOT
Soybeans CBOT
Wheat CBOT MATIF (ex-GBP) LIFFE
Cotton NYBOT ICE
Lumber CME
Urea FOB US Gulf FOB Arab Gulf
UAN 32% FOB New Orleans 30% FOT France
DAP CF New Orleans
Rubber RSS3 smoked sheets
Salmon Fishpool
Fishmeal 65% Peru CIF Germany
Cattle CME
Feeder CME
Hogs CME
Aluminium LME
Cobalt LME
Copper COMEX
Iron ore Steel home
Lead LME
Molybdenum MO3 CIF
Nickel LME
Rhodium spot NWE CIF
Tin LME
Zinc LME
Gold COMEX
Platinum NYMEX
Silver NYMEX
Palladium PAL

Appendix 4: Broad terms-of-trade inputs #

Official import / export price indices are sourced from national sources. Depending on how each country reports them, they belong to different statistical bulletins, and have either monthly or quarterly frequency. Romania is the only region releaseing the datapoint annually.

Hide code cell content
broad_df = pd.DataFrame(
    [
        {
            "Country": "Australia",
            "Source": "National statistical office",
            "Statistics group": "Balance of Payments",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Brazil",
            "Source": "FUNCEX",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Canada",
            "Source": "National statistical office",
            "Statistics group": "National accounts",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Chile",
            "Source": "Central bank",
            "Statistics group": "Import/Export Prices",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "China",
            "Source": "General Administration of Customs",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Colombia",
            "Source": "Central bank",
            "Statistics group": "Terms of Trade",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Czech Republic",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Euro Area 19",
            "Source": "Central bank",
            "Statistics group": "National accounts",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Hong Kong",
            "Source": "Census & Statistics Department (C&SD)",
            "Statistics group": "Trade",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Hungary",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "India",
            "Source": "Ministry of Commerce & Industry",
            "Statistics group": "Terms of Trade",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Indonesia",
            "Source": "National statistical office",
            "Statistics group": "Price Indices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Israel",
            "Source": "National statistical office",
            "Statistics group": "Trade",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Japan",
            "Source": "Ministry of Finance",
            "Statistics group": "Trade",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Malaysia",
            "Source": "National statistical office",
            "Statistics group": "Trade",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Mexico",
            "Source": "Central bank",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "New Zealand",
            "Source": "National statistical office",
            "Statistics group": "Trade",
            "Frequency": "Q",
            "Trade items": "Goods",
        },
        {
            "Country": "Norway",
            "Source": "National statistical office",
            "Statistics group": "Trade",
            "Frequency": "Q",
            "Trade items": "Goods",
        },
        {
            "Country": "Peru",
            "Source": "Central bank",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Philippines",
            "Source": "National statistical office",
            "Statistics group": "National Accounts",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Poland",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Romania",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "Y",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Russia",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Singapore",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods",
        },
        {
            "Country": "South Africa",
            "Source": "Central bank",
            "Statistics group": "Balance of Payments",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "South Korea",
            "Source": "Central bank",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Sweden",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods",
        },
        {
            "Country": "Switzerland",
            "Source": "Secretariat for Economic Affairs",
            "Statistics group": "National Accounts",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Taiwan",
            "Source": "Directorate-General of Budget",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "Thailand",
            "Source": "Bureau of Trade & Economic Indices",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods",
        },
        {
            "Country": "Turkey",
            "Source": "National statistical office",
            "Statistics group": "Trade",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "United Kingdom",
            "Source": "National statistical office",
            "Statistics group": "Import/Export Prices",
            "Frequency": "M",
            "Trade items": "Goods & Services",
        },
        {
            "Country": "United States",
            "Source": "Bureau of Economic Analysis",
            "Statistics group": "National accounts",
            "Frequency": "Q",
            "Trade items": "Goods & Services",
        },
    ]
).set_index("Country")
display(broad_df)
Source Statistics group Frequency Trade items
Country
Australia National statistical office Balance of Payments Q Goods & Services
Brazil FUNCEX Import/Export Prices M Goods & Services
Canada National statistical office National accounts Q Goods & Services
Chile Central bank Import/Export Prices Q Goods & Services
China General Administration of Customs Import/Export Prices M Goods & Services
Colombia Central bank Terms of Trade M Goods & Services
Czech Republic National statistical office Import/Export Prices M Goods & Services
Euro Area 19 Central bank National accounts Q Goods & Services
Hong Kong Census & Statistics Department (C&SD) Trade M Goods & Services
Hungary National statistical office Import/Export Prices M Goods & Services
India Ministry of Commerce & Industry Terms of Trade Q Goods & Services
Indonesia National statistical office Price Indices M Goods & Services
Israel National statistical office Trade Q Goods & Services
Japan Ministry of Finance Trade M Goods & Services
Malaysia National statistical office Trade M Goods & Services
Mexico Central bank Import/Export Prices M Goods & Services
New Zealand National statistical office Trade Q Goods
Norway National statistical office Trade Q Goods
Peru Central bank Import/Export Prices M Goods & Services
Philippines National statistical office National Accounts Q Goods & Services
Poland National statistical office Import/Export Prices M Goods & Services
Romania National statistical office Import/Export Prices Y Goods & Services
Russia National statistical office Import/Export Prices Q Goods & Services
Singapore National statistical office Import/Export Prices M Goods
South Africa Central bank Balance of Payments Q Goods & Services
South Korea Central bank Import/Export Prices M Goods & Services
Sweden National statistical office Import/Export Prices M Goods
Switzerland Secretariat for Economic Affairs National Accounts Q Goods & Services
Taiwan Directorate-General of Budget Import/Export Prices M Goods & Services
Thailand Bureau of Trade & Economic Indices Import/Export Prices M Goods
Turkey National statistical office Trade M Goods & Services
United Kingdom National statistical office Import/Export Prices M Goods & Services
United States Bureau of Economic Analysis National accounts Q Goods & Services

Appendix 5: Country-specific insights #

We summarise the main findings for South Africa below:

  • Methodological differences:

    • South Africa adopts two different deflators to derive imports and exports of goods at constant prices: Unit Value Indices (UVIs) are used for a subset of homogenous goods, whilst all other trade items are approximated via fx-adjusted PPI indices.

    • Price index aggregation happens in hierarchical fashion, starting from elementary Jevons indices that are combined into a Young index according to the appropriate weighting scheme.

  • Data differences:

    • Single-item import and export prices are reported by the South Africa Customs office as Free-on-Board (FOB), whilst commodity prices used in CTOT_NSA_PI indicators are a mix of FOB and CIF (Cost, Insurance, and Freight).

    • JPMaQS commodity-based price indices do not include iron and steel manufactured / semi-manufactured products, as we do not have a dedicated price series. These account for multiples (up to 5x) of Iron Ore exports in the early years.

    • South Africa is also using a generic country with code ZN, to represent the case when “Origin of Goods is Unknown”. For purposes of better understanding, this has been renamed to “Gold, Petroleum and Other” as over 95% of this bubble is made up of gold. Gold, due to legacy data rules, is treated as a country.

    • Due to the special trade reporting system South Africa is using (according to the IMTS 2010 manual), balance of payment adjustments are applied to gold, oil and aircraft. This different treatment recognizes the change of ownership of the goods to appropriately account for the transaction, instead of the usual physical movement across border as it happens for Customs-based rules.

With regards to New Zealand terms-of-trade, the main differences can be ascribed to:

  • Methodological differences:

    • New Zealand statistical office modified the methodology for import / export price indices, with changes effective from Sept 2003. Price indices are computed using a Fisher Ideal index (geometric average of Paasche and Laspeyres ones), using quarterly reference periods for price and annual reference periods for weights.

    • New Zealand adopts both Unit Value Indices (UVIs), for homogenous goods, and directly surveyed prices and FX-Rate adjusted international PPIs, for heterogeneous goods.

    • Price index aggregation happens at country-item (HS10) level, whilst it was happening at item level before 2003.

  • Data differences:

    • Single-item import prices are reported as Value for Duty (VFD), while export prices are FOB. Before 2003, imports were shown as CIF.

Appendix 6: Currency symbols #

The word ‘cross-section’ refers to currencies, currency areas or economic areas. In alphabetical order, these are AUD (Australian dollar), BRL (Brazilian real), CAD (Canadian dollar), CHF (Swiss franc), CLP (Chilean peso), CNY (Chinese yuan renminbi), COP (Colombian peso), CZK (Czech Republic koruna), DEM (German mark), ESP (Spanish peseta), EUR (Euro), FRF (French franc), GBP (British pound), HKD (Hong Kong dollar), HUF (Hungarian forint), IDR (Indonesian rupiah), ITL (Italian lira), JPY (Japanese yen), KRW (Korean won), MXN (Mexican peso), MYR (Malaysian ringgit), NLG (Dutch guilder), NOK (Norwegian krone), NZD (New Zealand dollar), PEN (Peruvian sol), PHP (Phillipine peso), PLN (Polish zloty), RON (Romanian leu), RUB (Russian ruble), SEK (Swedish krona), SGD (Singaporean dollar), THB (Thai baht), TRY (Turkish lira), TWD (Taiwanese dollar), USD (U.S. dollar), ZAR (South African rand).