Kalman Filter in Trading (2/2)
A Volatility-based Position Sizing
In the first part of this series, we introduced the Kalman filter from a theoretical perspective and discussed why it is a natural tool for online estimation problems.
In this second part, we move from theory to practice and show how a Kalman filter can be used in a real trading context. Not to predict returns, but to control risk dynamically.
The goal is simple: estimate volatility online and transform it into a stable, realistic position sizing rule.
Find all the codes here.
1. What problem are we actually solving?
Volatility is not constant. It changes over time, often abruptly, and usually when it matters the most.
Most traders rely on rolling volatility estimates. These approaches suffer from two major issues:
they react too slowly to regime changes,
they are extremely noisy at short horizons.
In live trading, what we really need is: an online estimate, reasonably smooth, but able to adapt when market conditions change.
This is a risk management problem, not a forecasting one.
2. Volatility as a latent variable
Volatility is not directly observable. What we observe are returns, which are highly noisy at the single-period level.
We therefore model volatility as a latent state variable. More precisely, we work with the log-variance:
This choice has three advantages:
it enforces positivity,
it leads to additive dynamics,
it is compatible with a linear Kalman filter.
3. From returns to an observable proxy
Since volatility cannot be observed directly, we construct a noisy proxy from returns:
Under a conditional Gaussian assumption, this quantity can be interpreted as a noisy observation of the latent log-variance.
This is clearly an approximation. However, our objective is not statistical inference, but stable risk control, which makes this approach both acceptable and effective in practice.
The visual difference already highlights the benefit of filtering.
4. Kalman filtering the log-variance
We model the latent state with a simple random walk:
and the observation equation:
Both noise terms are assumed Gaussian.
The two key parameters of the filter are:
Q, which controls how fast volatility is allowed to evolve,
R, which reflects how noisy the observation log(rt2) is.
In practice, R is kept relatively large, because squared returns are extremely noisy at short horizons.
5. From volatility estimation to position sizing
At this stage, we have an online estimate of volatility:
The key idea is to use this estimate to scale exposure such that portfolio risk remains approximately constant over time.
This leads to the target-volatility sizing rule:
This equation captures the core intuition:
when volatility increases, exposure is reduced,
when volatility decreases, exposure is increased.
Importantly, w_t is not a signal. It does not tell us which direction to trade. It only determines how much risk to take.
6. Practical constraints for live trading
In real trading systems, several safeguards are required.
First, a volatility floor prevents excessive leverage when estimated volatility becomes too small.
Second, exposure is capped to remain within acceptable leverage limits.
Finally, position weights are smoothed to reduce turnover and transaction costs:
This smoothing introduces a small delay, but significantly improves stability in practice.
7. What this approach does (and does not)
This framework works well because it:
stabilizes portfolio risk,
adapts to changing volatility regimes,
is simple, robust, and computationally efficient,
can be combined with any alpha signal.
However, it is important to be clear about its limitations:
it does not predict returns,
it does not perform market timing.
It is a risk controller, not an alpha generator.
Kalman filters are often presented as complex mathematical tools. In practice, their strength lies in their simplicity and flexibility.
Used correctly, they provide a clean and effective way to control risk in environments where volatility is unstable and noisy.
In systematic trading, improving risk control is often more impactful than improving return forecasts.
👉 If you want to go deeper into each step of the strategy building process, with real-life projects, ready-to-use templates, and 1:1 mentoring, that’s exactly what the Alpha Quant Program is for.




