Back to Docs
T
Traderoid

KalmanFilter Node

Recursive Bayesian noise reduction and signal extraction

StatisticalSmoothingEstimation

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

State Update
x̂(k) = ÷x̂(k-1) + K(k)·[z(k) - H·x̂(k-1)]
Estimate = Prior + Gain × (Observation - Expected)
K(k) = Gain (balance prediction vs observation)
Covariance Update
P(k) = [I - K(k)·H]·P̃(k)
P = Uncertainty (decreases as observations confirm predictions)

Parameters

ParameterDefaultDescription
process_noise1e-4How much system can change (Q)
measurement_noise1e-2Noise level in price (R)
initial_p1.0Initial 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

Related Nodes