Coverage for scripts/active_baseline.py: 100%

23 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-22 12:55 +0000

1"""As-live and idealized book of the CURRENT ml/ models on one split of a given dataset (V5.8.0). 

2 

3R-MODEL8 judges a retrained candidate against the "active" models scored on the SAME new splits, with their own scaler and 

4feature set: build that dataset first (`scripts/build_holdout_dataset.py --config-path <pre-V5.8.0 config> --windows-config 

5config.json`), run this BEFORE a pull replaces ml/, and run it again on the candidate's own dataset afterwards. 

6 

7 python scripts/active_baseline.py --split validation|backtest --dataset ml/datasets/v580_active_dataset.csv --out PATH 

8""" 

9 

10from __future__ import annotations 

11 

12import argparse 

13import json 

14import sys 

15from pathlib import Path 

16 

17ROOT_DIR = Path(__file__).resolve().parents[1] 

18sys.path.insert(0, str(ROOT_DIR)) 

19sys.path.insert(0, str(Path(__file__).resolve().parent)) 

20 

21from as_live_levers import AsLiveHarness, summarize # noqa: E402 

22 

23 

24def main() -> int: 

25 parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) 

26 parser.add_argument("--split", required=True, choices=["train", "validation", "backtest"]) 

27 parser.add_argument("--dataset", required=True) 

28 parser.add_argument("--out", required=True) 

29 parser.add_argument("--no-cache", action="store_true") 

30 args = parser.parse_args() 

31 harness = AsLiveHarness(args.split, use_cache=not args.no_cache, dataset_path=args.dataset) 

32 report = { 

33 "split": args.split, "dataset": args.dataset, "rows": int(len(harness.frame)), 

34 "as_live": summarize(harness.as_live()), "idealized": summarize(harness.idealized()), 

35 } 

36 Path(args.out).write_text(json.dumps(report, indent=2, default=float), encoding="utf-8") 

37 print(json.dumps({k: report[k]["net_sharpe"] for k in ("as_live", "idealized")})) 

38 return 0 

39 

40 

41if __name__ == "__main__": 

42 raise SystemExit(main())