ML Foundry, a Japanese stock forecasting platform, and the ML Trading viewer app
A personal project for trading Japanese stocks in my spare time: the ML Foundry forecasting platform and the ML Trading viewer app. It covers the speedups that finish parallel analysis with 16 scenario methods about 7 minutes after the information cutoff and then give trade candidates every 1 minute, the design that keeps future information out, and testing with MCP and parallel worktrees.
I am developing a forecasting platform, ML Foundry, and a macOS viewer app, ML Trading, on my own so I can trade Japanese stocks short term in my spare time. I built them as a hobby, for my own use. They are not a company service. The system does not use common technical indicators. It builds entry and exit candidates from the output of forecasting models, and I use them to decide my actual trades.
I set up a 1-year backtest environment on top of OSS, and tested and tuned several models whose forecast lines behave differently. Candidates come from an ensemble of these models. In the morning, parallel analysis with 16 scenario methods finishes about 7 minutes after the information cutoff (09:01). After that, the system forecasts entry and exit candidates from the current price every 1 minute.
I have also built a mechanism that runs automated trading in a browser with a tuned OSS model. I do not use it now, because a malfunction would have a large impact. I check candidates in the app and then place orders by hand on my broker’s screen. I do not disclose the trading strategy logic. This article explains the system structure, the speedups, and the design that keeps future information out.
Development time and repeated speed work
ML Trading started as viewing screens built in Grafana. I wanted more freedom to change the display and controls, so I moved it to a Tauri desktop app. The UI took shape in about 1 week. The core of the forecasting platform (ML Foundry), speed improvements and tuning, mechanisms that fit practical trading constraints, and validation on 1 year of backtests took about 2 months.

The parts I redid many times were optimizing the step that analyzes 16 scenario methods in parallel, rewriting code for CuPy, and backtest validation. For speed, I tried hot-loading models and data before the market opens, precomputing whatever could run ahead of time, and rewriting matrix operations for CuPy so calculations finish faster.
For prototyping and choosing what to keep, I used parallel Git worktrees. I had AI implement several improvement ideas at the same time, each in its own worktree, and also run the validation and write a result report. Then I compared them. I kept the ones that improved speed and results.

From the trading-day screen to review and improvement
I check and review trades in ML Trading. Around 1:29 in the video, the toggle at the top right of the screen is set to “Backtest” (バックテスト), and 2026-11-11 is open as the trading day.
The account summary is on the left, the stock list and detail panel are in the middle, and trade candidates are on the right. When you select a stock, the “Intraday chart” (当日チャート) shows that day’s actual prices with the forecasts overlaid.

The intraday chart shows forecasts with cutoffs just after the morning session (09:01) and the afternoon session (12:31) open. You can follow how the actual price moved across the lunch break, in 1-minute steps or as candlesticks. Widgets can be added to or removed from the detail panel. You can lay out a 20-trading-day forecast on daily bars, peer PER, margin balances, futures, and more, and save the layout.


Reopening the same trading day a few days later shows the same results. The app reads back the forecast records tied to the original run ID and cutoff time instead of recalculating on each view. For past days with no collected 1-minute bar records, it switches automatically to 1-minute bar snapshots built from the finalized execution data available after the close.
When a promising candidate appears, I use it for real trades in my spare time. Since around November the market has felt rough to me, so I keep working to make the backtests and candidates more resilient.
Most of the analysis data can be passed to AI as typed data through MCP. Lately I give the analysis data to AI, have it propose improvements, and take them through validation and reporting in parallel worktrees. This is how I look for combinations of models and strategies whose results hold up when the market changes. The mechanism below the chart that records my own entries and exits as teacher labels is also part of this improvement work.
Design choices
Separate systems for producing (ML Foundry) and viewing (ML Trading)
I split the roles into 2 systems so that collection and forecasting keep running during trading even when my Mac is not open, and so that heavy backtests do not get in the way of using the app.
| Role | ML Foundry (forecasting platform) | ML Trading (macOS viewer app) |
|---|---|---|
| Where it runs | Linux servers in my homelab | My local Mac (built with Tauri 2) |
| Responsibilities | Data collection, parallel analysis and inference, backtests | Chart display, candidate review, paper trading, teacher-label recording, CSV import |
| Data handling | Writes to and stores data in PostgreSQL, MinIO, and NATS | Read-only access to PostgreSQL and a local cache |
| Inference and orders | Inference in network-isolated GPU containers (no order placement) | No inference and no automated orders |
ML Trading uses only read-only transactions against the database. It caches up to 32 backtest comparison results locally to keep screen switching light. AI agents can read summaries and teacher labels through an MCP server that runs as a separate process.
Keeping forecasts, actuals, backtests, paper trades, and executions apart
If data finalized later or practice orders get mixed with real forecasts or account records, correct validation is not possible. ML Trading keeps the following 5 apart through the mode at the top of the screen and where each is stored.
| Category | What it records | Boundary that keeps it separate |
|---|---|---|
| Forecast | Price ranges and paths calculated only from what was available at the information cutoff | Cutoff time, publish time, and run ID are fixed and never overwritten later |
| Actual | Current prices during trading hours, or finalized 1-minute bars after the close | Kept as data separate from forecasts and only overlaid on screen |
| Backtest | Results of replaying the shared execution calculation on saved forecasts and actuals | Always records whether data was observed live or reconstructed from past data |
| Paper trading (demo) | Practice virtual trades tried locally against live candidates | Confined to a dedicated local account and never touches live account records |
| Executions (live) | Trades that filled after I placed orders by hand on my broker’s screen | Executions are never inferred from forecasts. They are confirmed only when the broker’s CSV is imported |
In “Live” (本番) mode, the app only notifies and displays candidates, and it stores data separately from the virtual trades in “Demo” (デモ) mode. Actual share holdings and trade history are confirmed only when a CSV file exported from the broker is imported.
Time constraints and offline execution that keep future information out
I use a paid J-Quants plan for forecasting and training. Same-day price data is normalized by my own collection process, and the charts are also built from J-Quants data.
If future information leaks into past forecasts in a backtest, only the apparent performance improves. ML Foundry applies 4 ordering constraints to incoming data, covering the time it became publishable, the time it was fetched, the time it was stored, and the time it was delivered. At each normalization stage, SQL tests also reject data whose order is broken.
When forecasts are reconstructed retroactively from past data, the system records that distinction and the reason, so they do not mix with real-time observations. Writes to object storage or local files cannot overwrite an existing key. The system also records hashes of the code and settings, and stops a backtest if a hash changes partway through.

Forecasts combine 3 time-series foundation models (TimesFM 2.5, Chronos-2, Timestral-209M) with 16 scenario methods. The GPU containers that run inference are cut off from external networks, and the model weight hashes are pinned. Backtests are started from the same screen. They use the same execution and cost calculator as live runs, so validation and real operation follow the same calculation rules.
Operating constraints and where the design applies
Because I place orders by hand, the app has to absorb differences in character encoding and format between the broker’s execution history CSV (which arrives a few days late) and the same-day execution CSV. Also, the macOS local network permission can block connections from outside the app. So tasks such as teacher-label sync can also run from the terminal or a batch job.
To keep experimenting with the forecasting logic, I set up boundaries that keep future information out, comparison of improvement ideas in parallel worktrees, and a review environment that separates live use from validation. The same approach can be used when developing data platforms for business systems or AI integration.
