Update veto.py
Browse files
veto.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
from typing import Dict, Any, Tuple
|
|
|
|
| 2 |
from config import (
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
)
|
| 7 |
|
| 8 |
|
|
@@ -14,20 +16,41 @@ def apply_veto(
|
|
| 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 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
if
|
| 25 |
-
reasons.append(f"
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
if reasons:
|
| 32 |
-
return True, "
|
| 33 |
return False, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from typing import Dict, Any, Tuple
|
| 2 |
+
|
| 3 |
from config import (
|
| 4 |
+
VETO_VOLUME_MIN,
|
| 5 |
+
VETO_VOL_RATIO_MAX,
|
| 6 |
+
VETO_STRUCTURE_MIN,
|
| 7 |
+
VETO_CLIMAX,
|
| 8 |
)
|
| 9 |
|
| 10 |
|
|
|
|
| 16 |
reasons = []
|
| 17 |
|
| 18 |
volume_score = volume_data.get("volume_score", 0.0)
|
|
|
|
|
|
|
|
|
|
| 19 |
vol_ratio = regime_data.get("vol_ratio", 1.0)
|
| 20 |
+
climax = volume_data.get("climax", False)
|
| 21 |
+
weak = volume_data.get("weak", False)
|
| 22 |
+
trend = regime_data.get("trend", "ranging")
|
| 23 |
+
vol_expanding = regime_data.get("vol_expanding", False)
|
| 24 |
+
vol_contracting = regime_data.get("vol_contracting", False)
|
| 25 |
+
atr_trend = regime_data.get("atr_trend", "falling")
|
| 26 |
|
| 27 |
+
if volume_score < VETO_VOLUME_MIN:
|
| 28 |
+
reasons.append(f"WEAK_VOLUME (score={volume_score:.2f}, threshold={VETO_VOLUME_MIN})")
|
| 29 |
|
| 30 |
+
if weak:
|
| 31 |
+
reasons.append(f"VOL_BELOW_MA (ratio={volume_data.get('vol_ratio', 0):.2f})")
|
| 32 |
+
|
| 33 |
+
if vol_ratio > VETO_VOL_RATIO_MAX:
|
| 34 |
+
reasons.append(f"EXTREME_VOLATILITY (ratio={vol_ratio:.2f}, max={VETO_VOL_RATIO_MAX})")
|
| 35 |
+
|
| 36 |
+
if structure_score < VETO_STRUCTURE_MIN:
|
| 37 |
+
reasons.append(f"CONFLICTING_STRUCTURE (score={structure_score:.2f}, threshold={VETO_STRUCTURE_MIN})")
|
| 38 |
+
|
| 39 |
+
if VETO_CLIMAX and climax:
|
| 40 |
+
reasons.append("CLIMAX_VOLUME (potential exhaustion)")
|
| 41 |
+
|
| 42 |
+
if trend == "bearish" and vol_expanding:
|
| 43 |
+
reasons.append("BEARISH_TREND_EXPANDING_VOL (high-risk combination)")
|
| 44 |
+
|
| 45 |
+
if vol_contracting and volume_score < 0.4:
|
| 46 |
+
reasons.append(f"VOL_CONTRACTING_WEAK_FLOW (vol_ratio={vol_ratio:.2f})")
|
| 47 |
|
| 48 |
if reasons:
|
| 49 |
+
return True, " | ".join(reasons)
|
| 50 |
return False, ""
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def veto_summary(vetoed: bool, reason: str) -> str:
|
| 54 |
+
if vetoed:
|
| 55 |
+
return f"VETOED — {reason}"
|
| 56 |
+
return "APPROVED"
|