Create veto.py
Browse files
veto.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, Any, Tuple
|
| 2 |
+
from config import (
|
| 3 |
+
VETO_VOLUME_MIN_SCORE,
|
| 4 |
+
VETO_VOLATILITY_MAX,
|
| 5 |
+
VETO_STRUCTURE_MIN_SCORE,
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def apply_veto(
|
| 10 |
+
regime_data: Dict[str, Any],
|
| 11 |
+
volume_data: Dict[str, Any],
|
| 12 |
+
structure_score: float,
|
| 13 |
+
) -> Tuple[bool, str]:
|
| 14 |
+
reasons = []
|
| 15 |
+
|
| 16 |
+
volume_score = volume_data.get("volume_score", 0.0)
|
| 17 |
+
if volume_score < VETO_VOLUME_MIN_SCORE:
|
| 18 |
+
reasons.append(f"volume_weak (score={volume_score:.2f})")
|
| 19 |
+
|
| 20 |
+
vol_ratio = regime_data.get("vol_ratio", 1.0)
|
| 21 |
+
if vol_ratio > VETO_VOLATILITY_MAX:
|
| 22 |
+
reasons.append(f"volatility_extreme (ratio={vol_ratio:.2f})")
|
| 23 |
+
|
| 24 |
+
if structure_score < VETO_STRUCTURE_MIN_SCORE:
|
| 25 |
+
reasons.append(f"structure_conflicting (score={structure_score:.2f})")
|
| 26 |
+
|
| 27 |
+
climax = volume_data.get("climax", False)
|
| 28 |
+
if climax:
|
| 29 |
+
reasons.append("climax_volume_detected")
|
| 30 |
+
|
| 31 |
+
if reasons:
|
| 32 |
+
return True, "; ".join(reasons)
|
| 33 |
+
return False, ""
|