# Kaufman Adaptive Moving Average (KAMA)

`D07-F01-A08` · Technical Indicators → Trend Smoothing · archetype `series-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/technical-indicators/trend-smoothing/kama/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { calculateKama } from "fintech-algorithms/technical-indicators/trend-smoothing/kama";
```

## Signature

```ts
calculateKama(values, efficiencyPeriod, fastPeriod, slowPeriod)
```

Kaufman adaptive moving average. The smoothing constant moves between a fast and a slow bound according to an efficiency ratio — directional travel divided by total travel — so the average tightens in a trend and loosens in noise.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `(number \| null)[]` | yes | Observation series in chronological order, oldest first. · nulls: propagate |
| `efficiencyPeriod` | `number` | yes | Lookback over which the efficiency ratio is measured. · min: 1, integer: true |
| `fastPeriod` | `number` | yes | Period defining the fast bound of the smoothing constant; reached when the series is perfectly directional. · min: 1, integer: true |
| `slowPeriod` | `number` | yes | Period defining the slow bound; reached when the series is pure noise. · min: 1, integer: true |

## Returns

`Record<string, (number | null)[]>` · length same-as-input

Parallel series: `efficiencyRatio`, `blendedAlpha`, `smoothingConstant` and `kama`, so the adaptation itself is inspectable rather than hidden inside the result.

## Warm-up

The first `efficiencyPeriod` positions are `null`. The efficiency ratio needs a full lookback before the constant is defined.

## Errors

- When any period is < 1, is not an integer, or fastPeriod ≥ slowPeriod — throws RangeError

## Complexity

Time `O(n)`, space `O(n)`.

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`values`:

```json
[100, 101, 102, 103, 104, 103]
```

Showing 6 of 16 elements.

`efficiencyPeriod`:

```json
10
```

`fastPeriod`:

```json
2
```

`slowPeriod`:

```json
30
```

### Call

```ts
calculateKama(values, efficiencyPeriod, fastPeriod, slowPeriod)
```

### Returns

object with 4 fields: efficiencyRatio, blendedAlpha, smoothingConstant, kama

```json
{
  "efficiencyRatio": [null, null, null, null, null, null],
  "blendedAlpha": [null, null, null, null, null, null],
  "smoothingConstant": [null, null, null, null, null, null],
  "kama": [null, null, null, null, null, null]
}
```

## Verification and provenance

Tier: **verified** (via scenario-fixture).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/technical-indicators/trend-smoothing/kama/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/technical-indicators/trend-smoothing/kama/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/technical-indicators/llms.txt
