Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Kalman Filter

Please see the attached algorithm for an implementation of a Kalman Filter in the analysis of time series data. The Kalman filter is an efficient recursive filter that estimates the state of a linear dynamic system from a series of noisy measurements. Like the Hidden Markov Model, the Kalman Filter develops an underlying Bayesian model, but the state space of the variables is continuous (as opposed to discrete with a HMM) and where all latent and observed variables have Gaussian distributions.

In this example, we apply the filter to the prices of Apple and Google. Please post if you have insight on how to improve the model or extend it to more securities!

http://en.wikipedia.org/wiki/Kalman_filter

3 responses

The stock market isn't a linear system. Shouldn't you be using another derivative of the algorithm, such as an unscented Kalman filter?

Geometric Brownian motion is a linear stochastic process and is the most widely used model for stock prices. Like the standard Kalman filter, the unscented Kalman filter is only useful with a sensible model for the state transition and observation.

Thank you both for your insight. The choice of a standard Kalman filter was a starting point and an illustrative example of how the technique can be implemented. A method that assumes a nonlinear underlying process, like the scented Kalman filter, may be more appropriate. While geometric Brownian motion is a linear stochastic process, it is linear with respect to the log-returns, not price.