v4.4.0: terminal instances + Strategy Tester optimization (modes 1/2/3) + .set generation
Lands PR #4 from algotradingspace/feat/strategy-optimizer (Marin).
Extends the v4.3.0 tester-mode terminal with full optimization
support, terminal cloning by instance name, and JSON-driven .set /
.ini generation.
Why this release
----------------
v4.3.0 added mode: backtest terminals but only covered single-pass
backtests with HTML reports. Optimization runs (Tester.Optimization
in 1, 2, 3) produce different artifacts: modes 1 and 2 emit an XML
optimization report, mode 3 ("all symbols") emits .symbols.xml plus
a binary .opt cache that MT5 never exposes through any documented
API. v4.4.0 adds parsers for both and a cache-shape probe so the
parser can adapt as MT5 ships new builds without code changes
per build.
Terminal instances also land here. The instance field on a
terminals[] entry lets the same broker/account pair appear more than
once (different ports, different portable data dirs) so a live
terminal can coexist with one or more backtest terminals on the
same login -- the exact use case that motivated the mode field in
v4.3.0.
New endpoints
-------------
POST /backtest/build-ini
Now accepts optimization (0..3) + optimizationCriterion (0..7)
alongside the v4.3.0 single-pass fields.
POST /backtest/build-set
Emit a Strategy Tester .set file from a JSON parameter list.
Supports both fixed values and optimization ranges (start /
step / stop / optimize), matching MT5's native
name=value||... format.
POST /backtest
New optional topPasses field (1..500) caps how many rows are
returned in optimizationResults. Defaults to 50.
GET /backtest/<jobId>
Optimization runs now populate optimizationType (0..3),
optimizationResults (top-N sorted passes), and
optimizationCache (metadata about the .opt cache parse:
profile name, byte offsets, MT5 build, symbol count). All
None for non-optimization runs.
GET /backtest/<jobId>/tail?lines=N
Live log tail across the run.log (terminal64.exe stdout),
the MT5 terminal journal, and the Strategy Tester sub-log.
Clamped to 10..1000 lines. Works while the job is queued,
running, or completed -- no need to wait for the report.
Config additions (config.yaml, all backwards compatible)
--------------------------------------------------------
terminals[].instance Optional terminal clone name. Missing /
empty resolves to "default" and keeps the
legacy /<broker>/<account>/ route alias.
Multiple entries on the same broker /
account pair need distinct instance values
to avoid colliding on the per-instance
portable data dir at
terminals/<broker>/<account>/<instance>/.
URL routing
-----------
Flat /<broker>/<account>/<instance>/... everywhere, with a clean
/<broker>/<account>/ alias when instance is omitted (the default
case). Mode-agnostic -- live and backtest terminals share the same
URL shape.
Cache parser
------------
mt5api/backtest/cache_parser.py reverse-engineers MT5's binary .opt
cache. The parser is profile-driven: candidate byte-offset layouts
are scored against the file and the best match wins. As MT5 ships
new builds with shifted layouts, append a new candidate to
OPT_CACHE_PROFILE_CANDIDATES -- no per-build code paths needed.
Symbol regex covers broker suffixes (EURUSD.r, GER40.cash,
Cocoa.c, #AAPL, etc.).
Warmup script
-------------
assets/experts/MT5SystemWarmup.mq5 (committed source, 19 lines) is
a single-purpose MQL5 script that primes a symbol's history cache
so the first /backtest call against it does not time out.
scripts/compile-warmup-ea.bat compiles it into MT5SystemWarmup.ex5
via the broker's bundled MetaEditor64.exe. The compiled .ex5 stays
gitignored.
Other fixes
-----------
- _kill_terminal path filter now scoped to BROKER\ACCOUNT\INSTANCE\*
so an instance restart cannot blast a sibling instance's terminal.
- CMD window title strips the /default suffix for default-instance
terminals.
- numpy<2 pin from v4.3.1 retained.
Commits
-------
5360c4d feat(config): add terminal instance settings
70f2aa3 feat(backtest): add optimization set parsing
5dbe1a6 Add proper MT5 mode 3 optimization support
63108df fix(backtest): relax symbol regex to handle broker
suffixes in opt cache
74070aa feat(backtest): add GET /backtest/<jobId>/tail for live
log polling
45f9412 fix skill (SKILL.md hardening for ClawHub SkillSpector)
1c2767f Merge pull request #4