Calculate the Commodity Channel Index (CCI) for a given price series.

The Commodity Channel Index is an oscillator that measures the current price level relative to an average price level over a specified period.

The formula is as follows:

\[\text{CCI} = (\text{Typical Price} - \operatorname{SMA}(\text{Typical Price})) / (\text{constant} \cdot \text{Mean Deviation})\]

Also known as: CCI, cyclical trend indicator.

Commodity Channel Index in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_commodity_channel_index as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["CLUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_commodity_channel_index().tail(5)

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

How did the Commodity Channel Index of crude oil move from 26 to 31 December 2025?

Which returns:

Date CLUSD Benchmark
2025-12-26 15.2689 120.245
2025-12-28 -1.512 88.9846
2025-12-29 51.2665 60.685
2025-12-30 69.184 49.5715
2025-12-31 38.1997 -1.7385

Parameters

get_commodity_channel_index accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”."weekly"
close_columnstrThe column in the historical data that represents Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way."Close"
windowintThe number of periods for calculating the CCI. Defaults to 14.20
constantfloatConstant multiplier used in the CCI calculation. Defaults to 0.015.0.02
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the indicator values. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. 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
Share