MIRA is a Python research framework for training financial forecasters, comparing models, and evaluating stock portfolios. It combines PyTorch models with Qlib data, chronological evaluation, portfolio simulation, and native diagnostic charts.
Start with an offline CPU demo, then use a verified daily market-data snapshot or import your own OHLCV data. Each research workflow saves its configuration, predictions, metrics, and provenance so results can be inspected and reproduced.
Getting started · Quick start · Model catalog · Hyperparameter search · Verified results · Documentation
Python 3.10–3.12 (3.12 recommended); CPU or NVIDIA CUDA. See platform-specific setup.
git clone https://github.com/BenjiKCF/MIRA.git
cd MIRA
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[neural,search,visualization]"For the reusable Linux CPU Docker environment, see runtime setup.
fts models
fts demo --model transformer --epochs 1 --device cpu --output runs/demoReuse the existing provider; download only if it is missing:
fts download-chenditc --provider .data/cn --release 2026-11-26
fts benchmark-cn --provider .data/cn --output runs/csi300
fts qlib-report --run-dir runs/csi300/lightgbm --output runs/csi300/plotsThe registered benchmark retains the original GLM model for reproducibility. New runs can use Inkling explicitly. Synthetic demo results are software checks, not market evidence. See the workflow guide for custom OHLCV, platform setup and CLI options.
The current default selection includes a tree baseline and seven neural architectures. Inkling 2 Mini supplies the active looping-Transformer structure. A ninth supported model, the earlier GLM loop, retains its original identity for replay and explicit comparisons. The *_mini models are independently implemented, randomly initialized adaptations of architecture ideas for numeric financial inputs. Their names identify the design inspiration; the model provenance and bibliography identifies the original papers or official technical releases and explains the retained and omitted components. Recent research hybrids use a separate search registry.
| CLI model | Main idea | Primary source / relationship | Configuration and notes |
|---|---|---|---|
lightgbm |
Gradient-boosted-tree baseline | Ke et al., NeurIPS 2017 | Config |
transformer |
Temporal self-attention baseline | Vaswani et al., NeurIPS 2017, numeric sequence adaptation | Config |
deepseek_v41_mini |
Compressed retrieval, shared KV reuse, hyper-connections, and experts | DeepSeek-AI, 2026 technical report/model card, local adaptation | Config · Architecture |
inkling2_mini |
Prelude, two shared middle blocks run three times, gated cross-pass messages and attention residuals, then coda | Thinking Machines Lab, Inkling 2 Mini, 2026 technical release, compact financial adaptation | Config · Architecture |
qwen4_mini |
Gated-delta mixing, sparse attention, and experts | Qwen Team, Qwen4-Max, 2026 technical release, local adaptation | Config · Architecture |
timesfm3_mini |
Patching, temporal/variate mixing, and forecast refinement | Jain and Sen, Google Research, 2026, local adaptation | Config · Architecture |
multiscale_residual_mixer |
Linear forecast path with multiscale convolution/MLP residuals | MIRA design; TSMixer / TimeMixer inspiration | Config · Architecture |
regime_linear_moe |
Linear experts combined by a historical-feature gate | MIRA design; Jacobs et al., 1991 MoE principle | Config · Architecture |
glm54_mini (historical) |
Shared Transformer body, first-pass sparse KV reuse and per-pass gates | Z.ai, GLM-5.4, 2026 technical release, earlier local adaptation | Replay config · Original architecture |
The active loop architecture is Inkling 2 Mini, with four stored layers and eight layer applications in its compact preset. The historical GLM adaptation remains supported for replay. The Inkling market HPO preset is available but has no completed market result.
fts hpo --provider .data/cn --config configs/hpo_inkling2_cpu.json --output runs/inkling2-hpoThe optional official TimesFM adapter uses separately licensed weights and distinct inputs; install .[timesfm] for it.
The frozen provider is chenditc 2026-11-26. Models use 157 OHLCV factors and historical CSI300 membership; native VWAP/index coverage was confirmed, but the full Alpha158 + 63 index descriptor contract is not yet qualified. The default target is close[t+2] / close[t+1] - 1; the separate five-day panel uses close[t+6] / close[t+1] - 1. All models use chronological splits, train-only preprocessing and validation-only selection; test dates and purges depend on each study. Benchmark protocol.
fts hpo --provider .data/cn --config configs/hpo_cpu.json --output runs/hpo-cpuThe search guide covers optimizers, dimensions, conditional parameters and reproducibility. Use a fresh output directory for each study.
The 2026 hybrid preset searches local adaptations of M²FMoE, SEMixer and optional EliMoE-inspired expert supervision. All results, including pruned spectral trials, are in the H3 trial report.
fts hpo --provider .data/cn --config configs/hpo_research2026.json --output runs/hpo-research2026Other studies: Part 4 ablations, five-day StockMamba-inspired panel, independent MIRA-R optimization. These are local adaptations, not official paper reproductions.
All results use the frozen 26 November 2026 chenditc snapshot and historical CSI300 membership (157 factors). One-day and five-day targets differ; rows are not a global ranking.
| Study / horizon | Model / origin | Params | Screen Rank IC | Validation Rank IC | Test IC | Test Rank IC | Test RMSE |
|---|---|---|---|---|---|---|---|
| H2/H3 · 1d | MIRA Regime Linear MoE (ours; H2 selected) | 10,850 | — | 0.085759 | 0.045572 | 0.056088 | 0.027062 |
| H3 · 1d | MIRA Mixer (ours; H3 selected) | 10,137 | — | 0.096642 | 0.019233 | 0.033131 | 0.027153 |
| H1 · 1d | MIRA Mixer (ours; H1 selected) | 10,137 | — | 0.095866 | 0.030474 | 0.045013 | 0.027116 |
| H2/H3 · 1d | Transformer control | 30,561 | — | 0.058010 | -0.031760 | -0.022207 | 0.027390 |
| H3 · 1d | Progressive Patch Mixer #15 (SEMixer-inspired) | 7,961 | 0.110486 | 0.084741 | — | — | — |
| H3 · 1d | Progressive Patch Mixer #16 (SEMixer-inspired) | 11,903 | 0.111391 | 0.079361 | — | — | — |
| H3 · 1d | Spectral Regime MoE #1 (M²FMoE-inspired) | 5,308 | 0.041552 | — | — | — | — |
| H3 · 1d | Spectral Patch MoE #3 (M²FMoE + SEMixer-inspired) | 10,606 | 0.095041 | — | — | — | — |
| B1 grid · 1d | MIRA Mixer (ours) | 10,137 | — | 0.101946 | — | — | — |
| B1 grid · 1d | MIRA Regime Linear MoE (ours) | 2,210 | — | 0.100095 | — | — | — |
| B1 grid · 1d | Progressive Patch Mixer (SEMixer-inspired) | 24,473 | — | 0.088204 | — | — | — |
| B1 grid · 1d | Spectral Patch MoE (M²FMoE + SEMixer-inspired) | 34,366 | — | 0.072984 | — | — | — |
| B1 grid · 1d | Spectral Regime MoE (M²FMoE-inspired) | 12,508 | — | 0.068213 | — | — | — |
| B1 protected · 1d | MIRA Mixer (protected H1 recipe) | 10,137 | — | 0.096642 | — | — | — |
| B1 protected · 1d | MIRA Regime Linear MoE (protected H2 recipe) | 10,850 | — | 0.085759 | — | — | — |
| B1 protected · 1d | Spectral Patch MoE (protected H3 #3 recipe) | 10,606 | — | 0.073814 | — | — | — |
| H2 control · 1d | LightGBM | — | — | -0.000340 | -0.035779 | -0.044406 | 0.027297 |
| H2 control · 1d | Ridge | — | — | 0.052894 | -0.014212 | -0.005785 | 0.027538 |
| H2 control · 1d | Zero return | 0 | — | — | — | — | 0.027160 |
| Panel · 5d | MIRA-R (ours; selected) | 61,928 | — | 0.093451 | -0.038107 | -0.019212 | 0.060733 |
| Panel · 5d | MIRA Multiscale Residual Mixer (ours) | 10,137 | — | 0.091986 | -0.016857 | 0.005627 | 0.059295 |
| Panel · 5d | MIRA Regime Linear MoE (ours) | 10,850 | — | 0.091446 | -0.016957 | 0.005488 | 0.059269 |
| Panel · 5d | Static market gate (local control) | 38,526 | — | 0.086074 | -0.134625 | -0.077748 | 0.062330 |
| Panel · 5d | Multiscale linear (local control) | 629 | — | 0.077793 | -0.029278 | -0.004417 | 0.059554 |
| Panel · 5d | StockMamba-inspired · rank | 61,038 | — | 0.060161 | -0.020989 | -0.015774 | 0.058827 |
| Panel · 5d | StockMamba-inspired · MSE | 61,038 | — | 0.038923 | -0.125929 | -0.088704 | 0.059065 |
| Panel · 5d | Zero return | 0 | — | — | — | — | 0.058355 |
| R-search · 5d | MIRA-R (ours; validation-selected) | 61,928 | — | 0.108933 | — | — | — |
Screen = single-seed, latest-fold completed H3 trial. Validation = mean across registered confirmation fits unless marked H2 control (one final fold). — means not evaluated, undefined or not applicable, never zero. H2 and H3 reproduced the same MoE/Transformer metrics on the same dates; these are shown once. H3's new hybrid finalists did not win validation, so their test scores were never evaluated.
Our models vs 2026 paper-inspired models (1d): In H3's two-fold, five-seed confirmation, MIRA Mixer scored 0.096642 validation Rank IC versus 0.084741 and 0.079361 for the SEMixer-inspired patch finalists; the MIRA MoE reference scored 0.085759. Mixer's lead over the best confirmed patch variant was +0.011902. These are descriptive averages for local adaptations. The spectral families were unconfirmed within H3; B1 reports their subsequent confirmation. This experiment does not establish superiority to the original papers' models.
H3 ran 24 trials (11 complete, 13 pruned): Spectral Regime MoE 1/3 completed, Progressive Patch Mixer 4/9, Spectral Patch MoE 5/11, Transformer 1/1. Only patch trials 15 and 16 advanced to two-fold, five-seed confirmation. All 24 trials, paper sources and exact recipes.
B1 balanced family comparison (1d; validation only): The common-grid winner was MIRA Mixer (ours) at 0.101946 Rank IC, +0.001850 above MIRA Regime Linear MoE (ours). Their mean ordering reversed between folds. The best protected recipe was MIRA Mixer (protected H1 recipe) at 0.096642; the difference (common-grid minus protected) was +0.005303. All 120 fits were verified. Equal new search budgets apply to the five common-grid families; protected recipes retain their earlier search history. These reused validation folds are not fresh market evidence. No B1 test or portfolio result was evaluated. Design and scope · All recipes and retained evidence.
Our models vs StockMamba-inspired models (5d): Across the 42 recovered and audited fits, MIRA-R won validation (0.093451 versus 0.060161 for StockMamba-inspired rank), but its historical test Rank IC was lower (-0.019212 versus -0.015774). MIRA Mixer and MoE had test Rank IC of 0.005627 and 0.005488; none of the seven learned arms beat zero-return RMSE. This was a recovered run. The separate 74-fit R-search retained the original MIRA-R recipe on validation only. Matched panel and external paper scope · Panel audit · R-search and all 12 challengers.
Native Qlib backtest (one-day, 41 portfolio days): H3 selected Mixer net return -10.646%; H2 MoE recipe -5.575%; CSI300 -14.128%. Both models lost money. Mixer report · MoE report · Costs and execution.
More evidence: All verified metrics and uncertainty · Balanced family protocol · 90-fit Part 4 ablations and 1/5/10-day heads · Matched controls and paired intervals · Historical benchmarks · Recovery and longer-history evidence gap. The 240-session HPO is log-only and excluded from verified scores; Inkling market results are not established. Reused historical tests do not establish prospective performance or profitability.
Start with getting started, model provenance and papers, all verified results, and research roadmap. For deployment and monitoring, see operations. Earlier results and evidence are retained in research history.
python -m pip install -e ".[dev,neural,search]"
ruff check src tests
python -m pytest -q
python scripts/render_results_overview.pyBuilt with Microsoft Qlib and PyTorch. The generated README scorecard is reproduced from retained study evidence; detailed tables and figures remain in the linked reports.