Skip to content
All library documents

KAMA Calculation, Initialization, and Python Input Errors

Article FMZ forum · Author: xaifer48

Summary

This forum question discusses two problems encountered while using Kaufman’s Adaptive Moving Average (KAMA) in a Python trading environment. First, a user reports that passing platform market records directly to the TA-Lib KAMA function fails because it expects a NumPy array. The user notes that an equivalent JavaScript call works, but the post offers no confirmed fix for converting or extracting the price series.

The main conceptual question concerns how to initialize KAMA’s recursive update. The author outlines an efficiency ratio based on net price movement divided by the sum of absolute price changes, combines it with fast and slow smoothing constants, and squares the result to obtain the adaptive coefficient. They ask where the prior KAMA value comes from for the first calculation. The page gives no reply or definitive initialization rule, so it documents an implementation question rather than a resolved procedure. It does not present tests or evidence comparing alternative initial values.

Key ideas

  • KAMA’s efficiency ratio compares net price movement with the sum of absolute price changes over a lookback period.
  • The adaptive smoothing coefficient is derived from fast and slow constants and then squared.
  • The recursive update requires a prior KAMA value, raising an initialization question for the first value.
  • The reported TA-Lib error indicates that the supplied records object is not the expected NumPy array type.
  • The post provides no verified fix or initialization method.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.