
Live inference on MT5 via ONNX.
From Research Abstraction to Trading Workflow
Many financial ML projects can describe sophisticated models but fail to close the loop between theory, deployment, and risk-aware evaluation. The Novel_Finance_ML project takes a different path. It frames prediction as a geometric and regime-sensitive problem, then carries that framing through dataset generation, PyTorch training, ONNX export, and live Expert Advisor execution in MetaTrader 5.

MT5 strategy optimizer results showing current performance of the model inference to excecution pipeline.
The architecture documented in this project is the Topological-Signature Koopman Selective State Space framework (TSK-S4). The key argument is simple: market data should not be treated as generic discrete tokens. Instead, it should be represented as continuous paths whose local geometry and regime context drive the model state transitions. This perspective aligns with the broader literature on rough path methods, selective state spaces, and Koopman-inspired dynamics.
Why This Framework Exists
The project addresses several failure modes common in financial sequence modeling:
- •
Distribution drift and abrupt regime shifts that break static temporal assumptions.
- •
High noise and low signal-to-noise ratios that can destabilize attention-heavy models.
- •
Feature-selection bias toward linear relationships in a strongly non-linear domain.
- •
Operational mismatch between offline model validation and cost-constrained execution.
Instead of relying on a single architectural trick, TSK-S4 uses multiple constraints and inductive biases. In practical terms, the stack is designed to behave less like curve fitting and more like a controlled dynamical system under uncertainty.
Core Mathematical Perspective
At the representation layer, the model maps recent market behavior into truncated log-signatures. Intuitively, this compresses path shape information (drift, cross interactions, curvature) into a compact state-driving vector. A stylized form used in the framework documentation is:
where is the recent multivariate path window and is the geometric summary used by downstream selective dynamics.
State evolution then follows a selective state-space update with explicit stability control:
with spectral normalization enforcing a contractive transition map,
This stability condition is central for long-horizon robustness in non-stationary streams and reflects the project's move toward mathematically constrained dynamics rather than unconstrained recurrence.
Composite Objective and Risk-Aware Outputs
The framework targets quantile predictions instead of single-point estimates, which is more aligned with trading decisions under uncertainty. The unified training objective in the project documents is structured as:
This decomposition introduces four practical controls:
- •
Quantile loss for distribution-aware forecasts and tail sensitivity.
- •
Martingale-style regularization to discourage economically inconsistent drift in return space.
- •
Koopman consistency to stabilize latent evolution under approximately linear operator structure.
- •
Regime diversity to prevent collapse when gating among latent experts.
For discretionary readers, this means the model is not only trying to predict direction; it is trying to shape a predictive distribution while respecting constraints that matter for real risk.

A look at the TSK-S4 training process. The steady decline in validation loss (orange) alongside the training loss (blue) demonstrates healthy convergence, aided by periodic adjustments to the learning rate.
Engineering Stack: What Makes It Deployable
Novel_Finance_ML is not a single notebook. It is an end-to-end system:
- •
Dataset and feature export in MT5 through MQL5 scripts and includes.
- •
Training in PyTorch with architecture and losses implemented in modular Python files.
- •
ONNX export for runtime portability.
- •
Execution via MT5 Expert Advisor integration using ONNX runtime.
- •
Edge diagnostics that test signals with cost-aware policy assumptions.
This pipeline orientation matters. A model can be statistically interesting and still fail in execution once spread, slippage, and sparse gating are applied. The project explicitly treats that gap as a first-class design problem.
What the Latest Diagnostics Suggest
The current project status reports that the stack has moved beyond pure "no-edge" behavior and into drawdown and performance shaping. The strongest signal from the recent diagnostics is not that every symbol is solved, but that practical gating and cost-aware checks can produce a viable edge profile in the current setup.
- •
Directional profile slightly above random baseline.
- •
Practical hit-rate improvements when only active, thresholded signals are traded.
- •
Positive risk-adjusted behavior under sparse-policy assumptions.
- •
Remaining bottleneck concentrated in cross-symbol drawdown dispersion.
In other words, the work ahead is increasingly portfolio-level and risk-allocation focused, not foundational architecture rescue.
Critical Lessons Encoded in the Project
Several implementation lessons in this repository are especially important for practitioners:
- •
Dataset semantics are non-negotiable; target alignment and row validation materially alter measured edge.
- •
Multi-symbol sequence construction must respect symbol boundaries to avoid leakage and false confidence.
- •
Sign-only evaluation is insufficient; cost-aware gating and slippage assumptions should be part of default diagnostics.
- •
A model that is promising in aggregate can still require strict symbol-level filtering before deployment.
These are not cosmetic details. They determine whether a model survives contact with execution reality.
How TSK-S4 Compares to Common Baselines
Compared with standard Transformer or LSTM workflows, TSK-S4 emphasizes path geometry, explicit stability, and differentiable regime logic. A concise framing is:
- •
Complexity target remains linear in sequence length through selective state-space design.
- •
Input representation shifts from discrete steps to continuous-path summaries.
- •
Output shifts from point predictions to quantile distributions for risk-aware decisioning.
- •
Regularization introduces economically motivated constraints beyond pure error minimization.
That combination is why this framework reads as an architectural strategy rather than a single model variant.
A Practical Roadmap from Here
Given the project's current state, the next high-value upgrades are clear:
Drawdown-constrained optimization in MT5 strategy testing loops.
Robustness sweeps across execution costs and slippage envelopes.
Conservative symbol onboarding, where weaker pairs remain opt-in until they pass risk-adjusted criteria.
Continuous validation of threshold policies under changing market regimes.
The repository already contains the structural pieces required to execute this plan. The remaining challenge is disciplined risk engineering.
Conclusion
TSK-S4 in Novel_Finance_ML is best understood as a production-minded financial intelligence stack: geometric encoding, selective state evolution, constrained optimization, and execution-aware validation. It does not claim that one model solves market complexity. It claims that architecture, data discipline, and risk-aware diagnostics must be designed together.
For teams building serious MT5 AI systems, that integration is the difference between a publishable experiment and a deployable process.
References
A Primer on the Signature Method in Machine Learning, arXiv: https://arxiv.org/pdf/1603.03788
Mamba: Linear-Time Sequence Modeling with Selective State Spaces, OpenReview: https://openreview.net/forum?id=tEYskw1VY2
Koopman Neural Forecaster for Time Series with Temporal Dynamics, arXiv: https://arxiv.org/pdf/2210.03675
Topological Data Analysis for Multivariate Time Series Data, PMC: https://pmc.ncbi.nlm.nih.gov/articles/PMC10669999/
Rough Path Theory and Signatures Applied to Quantitative Finance, QuantStart: https://www.quantstart.com/articles/rough-path-theory-and-signatures-applied-to-quantitative-finance-part-1/
Theoretical Foundations of Deep Selective State-Space Models, arXiv: https://arxiv.org/pdf/2402.19047