refine strategy variant lab
This commit is contained in:
@@ -118,15 +118,15 @@ def test_assigns_raw_and_residual_percentiles_independently():
|
||||
assert by_resid[0.10] == 0.0
|
||||
|
||||
|
||||
def test_spy_200_risk_scale_halves_risk_below_sma():
|
||||
base = date(2025, 1, 1)
|
||||
closes = {base + timedelta(days=i): 100.0 for i in range(210)}
|
||||
closes[base + timedelta(days=210)] = 80.0
|
||||
def test_strategy_variants_keep_only_current_research_candidates():
|
||||
variants = {cfg["variant"]: cfg for cfg in bt.STRATEGY_VARIANTS}
|
||||
|
||||
scale = bt._spy_200_risk_scale(closes)
|
||||
|
||||
assert scale[(base + timedelta(days=199)).toordinal()] == 1.0
|
||||
assert scale[(base + timedelta(days=210)).toordinal()] == 0.5
|
||||
assert "raw_80_regime_scaled" not in variants
|
||||
assert "residual_80_regime_scaled" not in variants
|
||||
assert "residual_90_fixed10" not in variants
|
||||
assert variants["raw_90_fixed15"]["max_positions"] == 15
|
||||
assert variants["residual_80_fixed20"]["max_positions"] == 20
|
||||
assert all(cfg["risk_scale"] is None for cfg in bt.STRATEGY_VARIANTS)
|
||||
|
||||
|
||||
def test_strategy_variant_sims_emit_fixed_variants_without_mutating_qualified(monkeypatch):
|
||||
@@ -169,7 +169,7 @@ def test_strategy_variant_sims_emit_fixed_variants_without_mutating_qualified(mo
|
||||
assert [r["variant"] for r in rows] == [cfg["variant"] for cfg in bt.STRATEGY_VARIANTS]
|
||||
assert all(call["exit_policy"] == "hold" for call in calls)
|
||||
assert any(call["ranking_key"] == "residual_momentum_percentile" for call in calls)
|
||||
assert any(call["max_positions"] == 15 for call in calls)
|
||||
assert any(call["max_positions"] == 20 for call in calls)
|
||||
assert cands[0]["qualified"] is False
|
||||
|
||||
|
||||
@@ -180,10 +180,12 @@ def test_build_research_recommendation_applies_promotion_rules():
|
||||
"max_drawdown_pct": 20.0, "cagr_pct": 30.0},
|
||||
{"variant": "residual_80_fixed10", "label": "Residual", "sharpe": 1.35,
|
||||
"max_drawdown_pct": 21.0, "cagr_pct": 31.0, "risk_scale": None},
|
||||
{"variant": "raw_80_regime_scaled", "label": "Scaled", "sharpe": 1.1,
|
||||
"max_drawdown_pct": 15.0, "cagr_pct": 27.0},
|
||||
{"variant": "residual_80_fixed20", "label": "Residual 20", "sharpe": 1.40,
|
||||
"max_drawdown_pct": 20.5, "cagr_pct": 32.0, "risk_scale": None},
|
||||
{"variant": "raw_90_fixed10", "label": "Cutoff 90", "sharpe": 1.25,
|
||||
"max_drawdown_pct": 19.0, "cagr_pct": 28.0},
|
||||
{"variant": "raw_90_fixed15", "label": "Cutoff 90 / 15", "sharpe": 1.30,
|
||||
"max_drawdown_pct": 18.0, "cagr_pct": 29.0},
|
||||
]},
|
||||
}
|
||||
|
||||
@@ -191,8 +193,9 @@ def test_build_research_recommendation_applies_promotion_rules():
|
||||
by_topic = {item["topic"]: item for item in rec["items"]}
|
||||
|
||||
assert by_topic["residual_momentum"]["candidate"] is True
|
||||
assert by_topic["regime_scaling"]["candidate"] is True
|
||||
assert "Residual 20" in by_topic["residual_momentum"]["text"]
|
||||
assert by_topic["cutoff_90"]["candidate"] is True
|
||||
assert "Cutoff 90 / 15" in by_topic["cutoff_90"]["text"]
|
||||
|
||||
|
||||
class TestStopFillR:
|
||||
|
||||
Reference in New Issue
Block a user