Consumer Price Index (CPI) is a measure that examines the average change in prices paid by consumers for goods and services over time. It is a measure of inflation.

By default the data is monthly, from the most current national source per country (see below). With period=”yearly” the data comes from the Global Macro Database (GMDB), annual with 2015 = 100. Set oecd_source=True to retrieve monthly or quarterly data from the OECD instead (base year varies per country).

With period=”monthly” and without oecd_source, every country comes from its most current source without an API key: Eurostat for the euro area and the European Economic Area (the HICP, 2015 = 100), the Office for National Statistics for the United Kingdom (CPI, 2015 = 100), the Statistics Bureau of Japan for Japan (CPI from 2015, on its latest base) and the Bank for International Settlements for every other country (2010 = 100). The base year differs between countries, so compare the changes rather than the levels.

Further information about the Global Macro Database (GMDB) variable can be found within https://www.globalmacrodata.com/documentation.html

Also known as: CPI, cost of living index.

Consumer Price Index in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_consumer_price_index as shown below.

from financetoolkit import Economics

economics = Economics(start_date='2008-09-01', end_date='2020-03-01')

economics.get_consumer_price_index(countries=['Germany', 'France', 'Portugal'], period='yearly')

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

How did the consumer price index of Germany, France and Portugal develop each year from 2008 to 2020?

Which returns:

  Germany France Portugal
2008 91.9238 93.2046 92.9047
2009 92.2236 93.2862 92.1285
2010 93.2552 94.7165 93.4207
2011 95.1772 96.7132 96.8332
2012 97.064 98.604 99.5189
2013 98.5364 99.4547 99.7919
2014 99.4445 99.9597 99.5142
2015 100 100 100
2016 100.467 100.184 100.608
2017 101.975 101.216 101.984
2018 103.765 103.09 102.998
2019 105.237 104.231 103.346
2020 105.801 104.729 103.333

Parameters

get_consumer_price_index accepts the following parameters.

ParameterTypeDescriptionExample
countrieslist[str] | str | NoneThe countries to include in the data. Defaults to None.["United States", "Germany"]
periodstr | NoneWhether to return the monthly, quarterly or the annual data. Without oecd_source=True, “monthly” uses the monthly sources described above and the annual data comes from the GMDB. Defaults to None, which is the monthly data (quarterly with oecd_source=True when the Economics class was initialized with quarterly=True)."monthly"
oecd_sourceboolWhether to get the data from the OECD instead of the Global Macro Database (GMDB). Defaults to False.True
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 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.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