KalmanFilter Node
Recursive Bayesian noise reduction and signal extraction
Overview
The Kalman Filter is a recursive algorithm that estimates the true state of a system from noisy measurements. It's optimal for linear systems with Gaussian noise and provides real-time signal smoothing without lag. Unlike moving averages, it adapts to changing noise levels and trends dynamically.
The filter combines predictions with observations, weighting them based on their uncertainty. High observation noise? Trust the model more. High prediction uncertainty? Trust observations more. This adaptive weighting makes it superior to fixed-window smoothing for trading signals, especially during regime changes.
Formula & Calculation
K(k) = Gain (balance prediction vs observation)
Parameters
| Parameter | Default | Description |
|---|---|---|
| process_noise | 1e-4 | How much system can change (Q) |
| measurement_noise | 1e-2 | Noise level in price (R) |
| initial_p | 1.0 | Initial uncertainty level |
Common Use Cases
1. Trend Extraction
Extract true price trend from noisy tick data. Kalman-filtered close better for signal generation than raw OHLC.
2. State Space Estimation
Estimate trend + noise components. Use trend for entry/exit, use noise for volatility-adaptive sizing.
3. Spread Prediction
Estimate next period's spread for pairs trading. Kalman adapts to cointegration strength changes.
4. Level Tracking
Track mean-reverting levels. Dynamic confidence levels trigger stronger signals when certainty is high.
Advantages & Limitations
Advantages
- Optimal for linear Gaussian systems
- Zero lag (true real-time)
- Adaptive to noise changes
- Theoretically elegant solution
Limitations
- Assumes Gaussian noise (often false)
- Parameter tuning critical
- Breaks during structural breaks
- Non-linear price dynamics