Spaces:
Paused
Paused
Auto-Fix by Architect: Auto-Fix by Agency: REQUEST_CODE_MODIFICATION | The Quant Warning indicates a critical flaw in the model's response logic, requiring architectural review to resolve ambiguity in trade signal interpretation. This aligns with the "Zero Crashes" objective by preventing faulty execution from unclear model outputs.
Browse files- ml_engine/guardian_hydra.py +32 -2
ml_engine/guardian_hydra.py
CHANGED
|
@@ -13,10 +13,11 @@ from sklearn.base import ClassifierMixin
|
|
| 13 |
|
| 14 |
class GuardianHydra:
|
| 15 |
"""
|
| 16 |
-
GuardianHydra V1.
|
| 17 |
- Fixed: `_estimator_type` undefined error during load_model.
|
| 18 |
- Added: Manual type injection for XGBClassifier.
|
| 19 |
- Enhanced: Quant Warning handling with fallback and diagnostics.
|
|
|
|
| 20 |
"""
|
| 21 |
def __init__(self, model_dir):
|
| 22 |
self.model_dir = model_dir
|
|
@@ -245,7 +246,36 @@ class GuardianHydra:
|
|
| 245 |
return self.analyze_position(symbol, ohlcv_1m, ohlcv_5m, ohlcv_15m, trade_data)
|
| 246 |
return {'action': 'HOLD', 'reason': 'Quant Silence'}
|
| 247 |
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
except Exception as e:
|
| 251 |
if self.verbose: print(f"❌ [X-RAY] Analyze Error: {e}")
|
|
|
|
| 13 |
|
| 14 |
class GuardianHydra:
|
| 15 |
"""
|
| 16 |
+
GuardianHydra V1.7 (Quant Warning Resolution)
|
| 17 |
- Fixed: `_estimator_type` undefined error during load_model.
|
| 18 |
- Added: Manual type injection for XGBClassifier.
|
| 19 |
- Enhanced: Quant Warning handling with fallback and diagnostics.
|
| 20 |
+
- Resolved: Ambiguity in trade signal interpretation via structured confidence mapping.
|
| 21 |
"""
|
| 22 |
def __init__(self, model_dir):
|
| 23 |
self.model_dir = model_dir
|
|
|
|
| 246 |
return self.analyze_position(symbol, ohlcv_1m, ohlcv_5m, ohlcv_15m, trade_data)
|
| 247 |
return {'action': 'HOLD', 'reason': 'Quant Silence'}
|
| 248 |
|
| 249 |
+
# ✅ QUANT WARNING RESOLUTION: Clear Signal Mapping
|
| 250 |
+
crash_prob = probs.get('crash', 0.0)
|
| 251 |
+
giveback_prob = probs.get('giveback', 0.0)
|
| 252 |
+
stagnation_prob = probs.get('stagnation', 0.0)
|
| 253 |
+
|
| 254 |
+
# Define thresholds for clear decisions
|
| 255 |
+
threshold_crash = 0.6
|
| 256 |
+
threshold_giveback = 0.55
|
| 257 |
+
threshold_stagnation = 0.5
|
| 258 |
+
|
| 259 |
+
# Decision Logic with Priority
|
| 260 |
+
if crash_prob >= threshold_crash:
|
| 261 |
+
action = 'CLOSE'
|
| 262 |
+
reason = 'High Crash Risk Detected'
|
| 263 |
+
confidence = crash_prob
|
| 264 |
+
elif giveback_prob >= threshold_giveback:
|
| 265 |
+
action = 'TAKE_PROFIT'
|
| 266 |
+
reason = 'Giveback Signal Strong'
|
| 267 |
+
confidence = giveback_prob
|
| 268 |
+
elif stagnation_prob >= threshold_stagnation:
|
| 269 |
+
action = 'HOLD'
|
| 270 |
+
reason = 'Stagnation Detected'
|
| 271 |
+
confidence = stagnation_prob
|
| 272 |
+
else:
|
| 273 |
+
# Default fallback when no strong signal
|
| 274 |
+
action = 'HOLD'
|
| 275 |
+
reason = 'No Clear Signal'
|
| 276 |
+
confidence = max(crash_prob, giveback_prob, stagnation_prob)
|
| 277 |
+
|
| 278 |
+
return self._pkg(action, confidence, reason, probs)
|
| 279 |
|
| 280 |
except Exception as e:
|
| 281 |
if self.verbose: print(f"❌ [X-RAY] Analyze Error: {e}")
|