A data-driven analysis applying Dynamic Mode Decomposition (DMD) to model complex dynamical systems for financial price prediction
Dynamic Mode Decomposition (DMD) is a powerful, data-driven "equation-free" algorithm that addresses this challenge. It analyzes a time-series of "snapshots" from a system and decomposes its complex spatio-temporal behavior into a set of low-rank, coherent structures called DMD modes. Each mode is associated with a specific oscillation frequency and a growth or decay rate (an eigenvalue). This allows us to build a simple, linear model that captures the dominant evolutionary patterns of the system.
📈 Financial Price Prediction: By treating the stock market as a complex dynamical system, we use DMD to identify dominant "growing modes" to predict price movements and inform trading strategies.
-
Source: National Stock Exchange (NSE500 Index)
-
Scope: Minute-wise stock prices of selected companies across sectors
-
Sampling Frequency: 1 minute
-
Training / Testing Split: 80/20
| Parameter | Description | Example |
|---|---|---|
| N | Number of companies | 10 |
| M | Number of time snapshots | 2000 |
| Δt | Sampling interval | 1 min |
| Observable | Stock price at time t | 245.5 ₹ |
We treat the stock market as a discrete-time dynamical system evolving as:
where ( x_k \in \mathbb{R}^n ) is the system state (vector of stock prices at time ( k )) and ( F ) is an unknown nonlinear mapping.
DMD approximates this system by finding a best-fit linear operator ( A ) such that:
The goal is to find ( A ) that minimizes the least-squares error between actual and predicted states.
Snapshots of the system are organized as:
We seek ( A ) satisfying:
The optimal approximation is given by:
where ( X^{+} ) is the Moore–Penrose pseudoinverse of ( X ).
To mitigate noise and reduce dimensionality, we compute the truncated Singular Value Decomposition (SVD):
where:
The reduced linear operator becomes:
We compute eigenvalues and eigenvectors of ( \tilde{A} ):
Then, the exact DMD modes are:
Each mode ( \phi_k) evolves in time as:
where:
and ( \lambda_k ) are the DMD eigenvalues.
If:
→ Growing mode → increasing stock value
If:
→ Decaying mode → decreasing stock value
Implemented using:
PyDMD— Python Dynamic Mode Decomposition library
Dataset: NSE500 stock price time series
Built using Streamlit with the following features:
- 📈 Stock Price Prediction — Predicts future stock movement using DMD reconstruction.
- 💹 Stock Recommendation — Ranks stocks by growing eigenvalues (positive real part).
- 🎨 Visualization Tools — Interactive plots for:
- DMD Modes
- Eigenvalue Spectra
- Temporal Dynamics
| 🧮 Metric | 📏 Value | 📖 Interpretation |
|---|---|---|
| MAE | 15.5299 |
Average absolute prediction error |
| MAPE | 1.94% |
Excellent short-term forecasting accuracy (less than 2% relative error) |
-
🔹 Eigenvalue Analysis: Revealed clear growing and decaying modes in the stock time series.
-
🔹 Accuracy: DMD effectively captured short-term market dynamics with minimal computational cost.
-
🔹 Visualization Insight: Stem plots of DMD modes showed distinct temporal oscillations and trend separations.
⚡ Insight:
The model demonstrates that Dynamic Mode Decomposition is not only effective for physical systems but also a powerful analytical tool in financial forecasting — offering interpretability, speed, and accuracy.
The growth rate (real part of eigenvalue) represents trend strength, while the complex part encodes cyclic behavior.
This allows ranking stocks by their dominant growing modes, forming the basis for automated trading recommendations.
.png)
.png)