Coverage for scripts/v660_trials.py: 100%
29 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"""The V6.6.0 trial list: every selectable candidate, fixed before any of them is scored (rules.json carries a copy)."""
3from __future__ import annotations
5import sys
6from pathlib import Path
8ROOT = Path(__file__).resolve().parents[1]
9sys.path.insert(0, str(ROOT))
11from evaluation.wide_context import BOND_ETF_CLASS, SECTOR_ETF_CLASS, SECTORS # noqa: E402
12from portfolio.premia_signals import DIRECT, TS, XS, SleeveSpec # noqa: E402
14TOP_K = 5
15CRYPTO_TOP_K = 10
16WINDOW_BY_TRACK = {"W": "S", "M": "S", "E": "S", "C": "CS"}
19def _wide(trial: str, every: int = 20, **params) -> SleeveSpec:
20 return SleeveSpec(trial, "W", XS, "external_score", SECTORS, every, {"table": trial, "top_k": TOP_K, **params})
23W = [_wide(f"w{number:02d}") for number in range(1, 14)] + [_wide("w14", every=5), _wide("w15")]
24WINDOW_OVERRIDES = {"w13": "SV"}
25M = [SleeveSpec(trial, "M", XS, "external_score", SECTORS, 20, {"table": trial, "top_k": TOP_K}) for trial in ("m1", "m2", "m3", "m4", "m5")]
26C = [
27 SleeveSpec("c1", "C", XS, "external_score", ("crypto",), 20, {"table": "c1", "top_k": CRYPTO_TOP_K}),
28 SleeveSpec("c2", "C", XS, "external_score", ("crypto",), 20, {"table": "c2", "top_k": CRYPTO_TOP_K}),
29 SleeveSpec("c3", "C", XS, "external_score", ("crypto",), 20, {"table": "c3", "top_k": CRYPTO_TOP_K}),
30 SleeveSpec("c4", "C", XS, "external_score", ("crypto",), 20, {"table": "c4", "top_k": CRYPTO_TOP_K}),
31 SleeveSpec("c5", "C", TS, "external_score", ("crypto",), 5, {"table": "c5"}),
32]
33E = [
34 SleeveSpec("e1", "E", XS, "cross_sectional_return", (SECTOR_ETF_CLASS,), 20, {"lookback": 126}),
35 SleeveSpec("e2", "E", XS, "cross_sectional_return", (BOND_ETF_CLASS,), 20, {"lookback": 126}),
36 SleeveSpec("e3", "E", DIRECT, "external_score", ("benchmark",), 21, {"table": "e3"}),
37]
38ALL_SPECS = [*W, *M, *C, *E]
39COMBINATION_IDS = ["t1", "t2"]
40CRYPTO_CORE = ("BTCUSD", "ETHUSD")
41# Time-series and single-asset trials have no cross-section for the rank-IC clause.
42NO_IC_CLAUSE = ("c5", "e3")
43# The fewest names a sleeve must be able to rank, on its rebalance days, for its score to mean anything.
44MIN_LIVE_NAMES = {"W": 150, "M": 150, "C": 12, "E": 5}
45# These hold a fixed few names by design.
46MIN_LIVE_NAMES_BY_TRIAL = {"c5": 2, "e3": 1}
47MIN_IC_NAMES = {"W": 20, "M": 20, "C": 8, "E": 5}
48PBO_COLUMNS = (
49 "w01", "w02", "w03", "w04", "w05", "w06", "w07", "w08", "w09", "w10", "w11", "w12", "w14", "w15", "m1", "m2", "m3", "m4", "m5", "e1", "e2", "e3",
50)
53def cell_of(spec: SleeveSpec) -> str:
54 return WINDOW_OVERRIDES.get(spec.id, WINDOW_BY_TRACK[spec.track])
57def min_live_names(trial: str, track: str) -> int:
58 return MIN_LIVE_NAMES_BY_TRIAL.get(trial, MIN_LIVE_NAMES[track])