Weighted Moving Average (WMA) calculator for the command line. Zero dependencies.
Recent values receive linearly increasing weights — useful for financial data, time series smoothing, and signal processing.
npm i -g @kszongic/wma-cli# From arguments
wma 10 20 30 40 50 --window 3
# From stdin
echo "10 20 30 40 50" | wma -w 3
# Pipe from seq
seq 10 | wma -w 4
# JSON output
wma 1 2 3 4 5 -w 3 --json| Flag | Description |
|---|---|
-w N, --window N |
Window size (default: all input) |
--json |
Output as JSON array |
-h, --help |
Show help |
For window size w, each value in the window gets weight 1, 2, ..., w (most recent = highest weight):
WMA = (w₁·1 + w₂·2 + ... + wₙ·n) / (1 + 2 + ... + n)
$ echo "10 20 30 40 50" | wma -w 3
10
16.666667
23.333333
33.333333
43.333333MIT © 2026 kszongic