Isolate residual S/R target selection
This commit is contained in:
@@ -94,9 +94,14 @@ HORIZON = 30 # trading days to resolve an outcome (matches the evaluat
|
||||
ATR_MULTIPLIER = 1.5
|
||||
RANGE_FACTOR_LOOKBACK = 504
|
||||
RANGE_FACTOR_MIN_LOG = 1.0 # approximately a 2.7x high/low span
|
||||
RANGE_RESIDUAL_VARIANTS = {
|
||||
"rewrite_range504_structural_legacy_primary",
|
||||
"rewrite_range504_structural_primary2",
|
||||
}
|
||||
RANGE_FACTOR_VARIANTS = {
|
||||
"production_range504",
|
||||
"rewrite_range504_legacy_primary",
|
||||
*RANGE_RESIDUAL_VARIANTS,
|
||||
}
|
||||
|
||||
# Cross-sectional signal evaluation (factor IC). Each candidate signal is a
|
||||
@@ -169,7 +174,10 @@ def _sr_detector_variant(sr_variant: str) -> str:
|
||||
"""Map factor-gated research arms to the detector they hold fixed."""
|
||||
if sr_variant == "production_range504":
|
||||
return "production_control"
|
||||
if sr_variant == "rewrite_range504_legacy_primary":
|
||||
if (
|
||||
sr_variant == "rewrite_range504_legacy_primary"
|
||||
or sr_variant in RANGE_RESIDUAL_VARIANTS
|
||||
):
|
||||
return "rewrite"
|
||||
return sr_variant.removesuffix("_legacy_primary")
|
||||
|
||||
@@ -195,6 +203,17 @@ def _range_factor_allows(sr_variant: str, range_504_log: float) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def _primary_min_rr_for_variant(sr_variant: str, activation: dict) -> float:
|
||||
"""Preserve the deployed selector except in explicit primary-2 research."""
|
||||
if (
|
||||
sr_variant in {"production_control", "production_range504"}
|
||||
or sr_variant.endswith("_legacy_primary")
|
||||
or sr_variant.startswith("legacy_")
|
||||
):
|
||||
return 1.5
|
||||
return float(activation.get("min_rr", 0.0))
|
||||
|
||||
|
||||
def _apply_zone_strength_variant(zone_levels: list[Any], sr_variant: str) -> list[Any]:
|
||||
"""Apply post-cluster research controls without changing zone geometry."""
|
||||
if sr_variant in {"legacy_geometry_neutral", "legacy_range_grid_neutral"}:
|
||||
@@ -363,6 +382,7 @@ def _window_setups(
|
||||
gate_levels = _gate_eligible_levels(
|
||||
sr_levels,
|
||||
confirmed_rounds_only=detector_variant in {"confirmed_rounds", "gate_v2"},
|
||||
exclude_standalone_rounds=sr_variant in RANGE_RESIDUAL_VARIANTS,
|
||||
)
|
||||
zone_strength_mode = (
|
||||
"soft"
|
||||
@@ -406,13 +426,7 @@ def _window_setups(
|
||||
# Collapse duplicate floor-pinned lottery targets (parity with
|
||||
# enhance_trade_setup).
|
||||
targets = _prune_floor_pinned_targets(targets)
|
||||
primary_min_rr = (
|
||||
1.5
|
||||
if sr_variant in {"production_control", "production_range504"}
|
||||
or sr_variant.endswith("_legacy_primary")
|
||||
or sr_variant.startswith("legacy_")
|
||||
else float(activation.get("min_rr", 0.0))
|
||||
)
|
||||
primary_min_rr = _primary_min_rr_for_variant(sr_variant, activation)
|
||||
primary = _select_primary_target(
|
||||
targets,
|
||||
min_rr=primary_min_rr,
|
||||
|
||||
@@ -60,6 +60,7 @@ def _gate_eligible_levels(
|
||||
sr_levels: list[Any],
|
||||
*,
|
||||
confirmed_rounds_only: bool = False,
|
||||
exclude_standalone_rounds: bool = False,
|
||||
min_round_rejections: int = 2,
|
||||
) -> list[Any]:
|
||||
"""Return structures allowed to influence entry qualification.
|
||||
@@ -69,7 +70,7 @@ def _gate_eligible_levels(
|
||||
either confluence with a pivot/volume source or distinct rejection clusters
|
||||
before such a level is allowed to manufacture a gate target.
|
||||
"""
|
||||
if not confirmed_rounds_only:
|
||||
if not confirmed_rounds_only and not exclude_standalone_rounds:
|
||||
return list(sr_levels)
|
||||
|
||||
eligible: list[Any] = []
|
||||
@@ -79,8 +80,11 @@ def _gate_eligible_levels(
|
||||
])
|
||||
is_round_only = sources == {"round_number"}
|
||||
rejections = int(getattr(level, "rejection_count", 0) or 0)
|
||||
if not is_round_only or rejections >= min_round_rejections:
|
||||
eligible.append(level)
|
||||
if exclude_standalone_rounds and is_round_only:
|
||||
continue
|
||||
if confirmed_rounds_only and is_round_only and rejections < min_round_rejections:
|
||||
continue
|
||||
eligible.append(level)
|
||||
return eligible
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user