Coverage for scripts/build_trial_registry.py: 100%
19 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 12:55 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 12:55 +0000
1"""Every research variant ever scored by a pre-registered rule, as one trial list (V6.3.0) -> the deflated Sharpe ratio's
2N and Sharpe variance (`evaluation/backtest_statistics.py`, README "Return/Risk Efficiency").
4Each rule chain's `ml/evaluation/<phase>/research.json` stores, per variant and scoring mode, one summary per split with
5`median_net_sharpe` over the rebalance phases. A trial is one (phase, stage, variant, mode) scored on the backtest split
6(the split variants were selected on); a summary repeated verbatim (the base book re-scored in every stage) counts once.
8 python scripts/build_trial_registry.py [--evaluation-dir ml/evaluation] [--out ml/evaluation/trial_registry.json]
9"""
11from __future__ import annotations
13import argparse
14import json
15import sys
16from pathlib import Path
18ROOT = Path(__file__).resolve().parents[1]
19sys.path.insert(0, str(ROOT))
21from evaluation.trial_registry import SPLIT, build_registry, collect_trials, dedupe # noqa: E402,F401
24def main() -> int:
25 parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
26 parser.add_argument("--evaluation-dir", type=Path, default=ROOT / "ml" / "evaluation")
27 parser.add_argument("--out", type=Path, default=ROOT / "ml" / "evaluation" / "trial_registry.json")
28 args = parser.parse_args()
29 registry = build_registry(args.evaluation_dir)
30 args.out.write_text(json.dumps(registry, indent=2), encoding="utf-8")
31 print(f"{registry['num_trials']} trials from {', '.join(registry['sources']) or 'no research files'} -> {args.out}")
32 return 0
35if __name__ == "__main__":
36 raise SystemExit(main())