Summary
Kama is RTTA's streaming Kaufman Adaptive Moving Average. It speeds up for an
efficient directional path and slows down when the same net movement contains
more back-and-forth noise.
Update API
result = rtta.Kama(
window=10, fast_ema=2, slow_ema=30, fillna=True
).update(close)
advance(...) consumes the same close without materializing a Python return
value. batch(...) applies the identical state transition to an array.
Theory Of Operation
KAMA uses Kaufman's efficiency ratio (net displacement divided by path length) to interpolate between fast and slow EMA constants. Squaring the interpolated constant makes the average especially resistant to choppy price noise while remaining responsive to a clean trend.
Recurrence
For efficiency window \(n\), fast period \(f\), and slow period \(s\):
The calculation needs \(n+1\) closes to obtain \(n\) real one-step changes.
Until then, price is retained as the KAMA seed. fillna=True returns that price
during startup; fillna=False returns NaN. The first complete value is thus
emitted on update \(n+1\), matching TA-Lib's canonical sequence.
Composed Primitives
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in class Kama.
Startup changes are computed only between observed closes; no synthetic zero
price is inserted into the path length.
