Commodity Channel Index
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.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”. | "weekly" |
close_column | str | The 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" |
window | int | The number of periods for calculating the CCI. Defaults to 14. | 20 |
constant | float | Constant multiplier used in the CCI calculation. Defaults to 0.015. | 0.02 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the indicator values. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |