# Kalman Filter

## Intro

- Kalman filter is a recursive algorithm that estimates the true state of a system in the presence of noise. Thus, it is known as a smoothing technique.
- In Machine learning, it’s an unsupervised learning algorithm so you don’t need to select a window length. This helps to avoid overfitting, but does not guarantee to remove it.

## Qualitative Definition

The Kalman filter is a recursive algorithm that at each time step, the algorithm estimates the current state of the system using the transition matrix, takes in new measurements, and then updates the estimated current state.

- Transition matrix tells the algorithm how the system evolves from one state to another.

## Trading

- In trading, system is the market, state is the price of an asset, and noise is the uncertainty of the price.
- Quants use it as a smooth trading indicator to reduce the noise of the price and to signal trading opportunities.
- Useful for computing the moving average or for smoothing out estimates of other quantities. For example, if you have already computed the Sharpe ratio of a portfolio to measure its risk-adjusted performance, you can use a Kalman filter to smooth out the estimate of the Sharpe ratio.

### Implementation

List of things we want to do in this example:

- Get stock price data using OpenBB SDK (similar like a Bloomberg terminal/SDK, but an open-source investment research software platform for backtesting and other quantitative analysis)
- Build a moving average model using Kalman filter

*View Jupyter notebook in full screen! Download it here!*

Permalink athttps://www.physicslog.com/cs-notes/qf/kalman-filter

Published onJan 15, 2023

Last revised onJan 15, 2023

References