Document S/R findings and isolate legacy gate features
This commit is contained in:
@@ -141,6 +141,9 @@ SR_RESEARCH_VARIANTS = {
|
||||
"soft_zones_legacy_primary",
|
||||
"confirmed_rounds_legacy_primary",
|
||||
"gate_v2_legacy_primary",
|
||||
"legacy_geometry_neutral",
|
||||
"legacy_pivots_only",
|
||||
"legacy_traffic_grid_only",
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +276,19 @@ def _window_setups(
|
||||
|
||||
sr_variant = _sr_research_variant()
|
||||
detector_variant = sr_variant.removesuffix("_legacy_primary")
|
||||
if detector_variant in {"production_control", "rr_aligned_control"}:
|
||||
if sr_variant == "legacy_geometry_neutral":
|
||||
detected_levels = detect_sr_levels_legacy(
|
||||
highs, lows, closes, volumes, neutral_strength=True
|
||||
)
|
||||
elif sr_variant == "legacy_pivots_only":
|
||||
detected_levels = detect_sr_levels_legacy(
|
||||
highs, lows, closes, volumes, include_volume_profile=False
|
||||
)
|
||||
elif sr_variant == "legacy_traffic_grid_only":
|
||||
detected_levels = detect_sr_levels_legacy(
|
||||
highs, lows, closes, volumes, include_pivots=False
|
||||
)
|
||||
elif detector_variant in {"production_control", "rr_aligned_control"}:
|
||||
detected_levels = detect_sr_levels_legacy(highs, lows, closes, volumes)
|
||||
else:
|
||||
detector_cap = 0 if detector_variant == "gate_v2" else MAX_LEVELS
|
||||
@@ -331,7 +346,9 @@ def _window_setups(
|
||||
targets = _prune_floor_pinned_targets(targets)
|
||||
primary_min_rr = (
|
||||
1.5
|
||||
if sr_variant == "production_control" or sr_variant.endswith("_legacy_primary")
|
||||
if sr_variant == "production_control"
|
||||
or sr_variant.endswith("_legacy_primary")
|
||||
or sr_variant.startswith("legacy_")
|
||||
else float(activation.get("min_rr", 0.0))
|
||||
)
|
||||
primary = _select_primary_target(
|
||||
|
||||
+28
-14
@@ -400,25 +400,36 @@ def detect_sr_levels_legacy(
|
||||
closes: list[float],
|
||||
volumes: list[int],
|
||||
tolerance: float = DEFAULT_TOLERANCE,
|
||||
*,
|
||||
include_volume_profile: bool = True,
|
||||
include_pivots: bool = True,
|
||||
neutral_strength: bool = False,
|
||||
) -> list[dict]:
|
||||
"""Exact research control for the deployed pre-rewrite detector."""
|
||||
"""Deployed detector plus source-isolation controls for local research.
|
||||
|
||||
The defaults remain the exact production control. Keyword-only switches
|
||||
allow a research arm to remove one source or neutralize strength without
|
||||
copying or subtly changing the legacy implementation.
|
||||
"""
|
||||
if not closes:
|
||||
return []
|
||||
|
||||
candidates: list[tuple[float, str]] = []
|
||||
try:
|
||||
for price in _legacy_volume_profile_nodes(highs, lows, closes, volumes):
|
||||
candidates.append((float(price), "volume_profile"))
|
||||
except ValidationError:
|
||||
pass
|
||||
try:
|
||||
pivots = compute_pivot_points(highs, lows, closes)
|
||||
candidates.extend(
|
||||
(float(price), "pivot_point")
|
||||
for price in pivots.get("swing_highs", []) + pivots.get("swing_lows", [])
|
||||
)
|
||||
except ValidationError:
|
||||
pass
|
||||
if include_volume_profile:
|
||||
try:
|
||||
for price in _legacy_volume_profile_nodes(highs, lows, closes, volumes):
|
||||
candidates.append((float(price), "volume_profile"))
|
||||
except ValidationError:
|
||||
pass
|
||||
if include_pivots:
|
||||
try:
|
||||
pivots = compute_pivot_points(highs, lows, closes)
|
||||
candidates.extend(
|
||||
(float(price), "pivot_point")
|
||||
for price in pivots.get("swing_highs", []) + pivots.get("swing_lows", [])
|
||||
)
|
||||
except ValidationError:
|
||||
pass
|
||||
if not candidates:
|
||||
return []
|
||||
|
||||
@@ -469,6 +480,9 @@ def detect_sr_levels_legacy(
|
||||
)
|
||||
|
||||
_tag_levels(merged, closes[-1])
|
||||
if neutral_strength:
|
||||
for level in merged:
|
||||
level["strength"] = 50
|
||||
merged.sort(key=lambda row: row["strength"], reverse=True)
|
||||
return merged
|
||||
|
||||
|
||||
Reference in New Issue
Block a user