Calculate the Kaufman Adaptive Moving Average (KAMA) for a given price series.

The Kaufman Adaptive Moving Average adjusts its own responsiveness to price changes based on how “efficiently” price is moving. It compares the net directional move over the window to the total (sum of absolute) movement over that same window - the Efficiency Ratio. When price trends strongly in one direction (an efficient move), the Efficiency Ratio is close to 1 and KAMA tracks price closely, behaving like a fast EMA. When price whipsaws sideways (an inefficient move), the Efficiency Ratio is close to 0 and KAMA flattens out, behaving like a slow EMA - reducing whipsaw signals in choppy markets while still reacting quickly during strong trends.

The formula is as follows:

\[\text{Change} = | \operatorname{Close}(t) - \operatorname{Close}(t - \text{window}) |\] \[\text{Volatility} = \operatorname{Sum}(| \operatorname{Close}(i) - \operatorname{Close}(i - 1) |,\; \text{window})\] \[\text{Efficiency Ratio} (\text{ER}) = \text{Change} / \text{Volatility}\] \[\text{Fastest SC} = 2 / (\text{fast\_window} + 1),\;\; \text{Slowest SC} = 2 / (\text{slow\_window} + 1)\] \[\text{Smoothing Constant} (\text{SC}) = \left[\text{ER} \cdot (\text{Fastest SC} - \text{Slowest SC}) + \text{Slowest SC}\right] ^{2}\] \[\operatorname{KAMA}(t) = \operatorname{KAMA}(t-1) + \text{SC} \cdot (\operatorname{Close}(t) - \operatorname{KAMA}(t-1))\]

Also known as: KAMA, Kaufman’s Adaptive Moving Average.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Kaufman Adaptive Moving Average (KAMA) for you. Just ask in plain English.

Calculate the Kaufman Adaptive Moving Average (KAMA) in Python

The Kaufman Adaptive Moving Average (KAMA) is available in the Technicals module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_kaufman_adaptive_moving_average as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(tickers=["AAPL", "MSFT"])

toolkit.technicals.get_kaufman_adaptive_moving_average()

Parameters

get_kaufman_adaptive_moving_average accepts the following parameters:

  • period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
  • close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
  • window (int, optional): Number of periods over which the Efficiency Ratio is calculated. Defaults to 10.
  • fast_window (int, optional): The number of periods that corresponds to the fastest EMA constant used when the Efficiency Ratio is at its maximum (1.0). Defaults to 2.
  • slow_window (int, optional): The number of periods that corresponds to the slowest EMA constant used when the Efficiency Ratio is at its minimum (0.0). Defaults to 30.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the KAMA. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.

The Technicals module page introduces the module, and the sidebar lists all of its functions.

Share