Skip to content

Kaufman Adaptive Moving Average

KAMA adapts to market volatility, offering a more responsive moving average.

Method

tm.ta.kama(source, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator30

Outputs

OutputType
kamanp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Kaufman Adaptive Moving Average
kama = tm.ta.kama(data.close, timeperiod=30)
# Get the last value and print
last_value = kama.iloc[-1]
tm.log(f"Last value of Kaufman Adaptive Moving Average is {last_value}")
# Plot the values of kama
tm.plot(kama, title="Kaufman Adaptive Moving Average", overlay=False)