Discussing the article: "Neural Networks in Trading: Probabilistic Time Series Forecasting (K2VAE)"

 

Check out the new article: Neural Networks in Trading: Probabilistic Time Series Forecasting (K2VAE).

We invite you to explore the original implementation of the K²VAE framework — a flexible model capable of linearly approximating complex dynamics in latent space. This article demonstrates how to implement key components in MQL5, including parameterized matrices and how to manage them outside standard neural network layers. This material will be useful for anyone looking for a practical approach to building interpretable time-series models.

Classical models are excellent at making short-term forecasts. But look a little further ahead, and errors begin to accumulate, volatility amplifies inaccuracies, and computational costs skyrocket. This is especially true in financial markets, where every event — whether a corporate earnings report or a geopolitical surprise — introduces nonlinearity and changes the rules of the game.

As one possible approach to solving this type of problem, a new framework based on two fundamental ideas was proposed in the paper "K²VAE: A Koopman-Kalman Enhanced Variational AutoEncoder for Probabilistic Time Series Forecasting." First, Koopman theory converts nonlinear processes into a linear form. Imagine that you are looking at a stock price chart through special lenses, and it turns into a straight line — this approach makes it easier to understand the dynamics. Second, the classic Kalman filter carefully processes new data, adjusting the forecast every time new information becomes available: an earnings report, a change in interest rates, or an unexpected event.

The authors of the paper combined these ideas into the K²VAE framework — a lightweight and fast system based on a variational autoencoder. First, KoopmanNet imposes a linear structure on historical price data and indicators. Then, KalmanNet, built on Kalman filter methods, refines the estimates of possible movements and their uncertainty step by step. This architecture enables forecasting over both short- and long-term horizons while maintaining high accuracy and stability.


Author: Dmitriy Gizlyk