Document S/R findings and isolate legacy gate features
This commit is contained in:
+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