Spaces:
Paused
Paused
Update ml_engine/data_manager.py
Browse files- ml_engine/data_manager.py +30 -21
ml_engine/data_manager.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# ============================================================
|
| 2 |
# 📂 ml_engine/data_manager.py
|
| 3 |
-
# (V67.
|
| 4 |
# ============================================================
|
| 5 |
|
| 6 |
import asyncio
|
|
@@ -44,7 +44,7 @@ class DataManager:
|
|
| 44 |
'UP', 'DOWN', 'BEAR', 'BULL', '3S', '3L'
|
| 45 |
]
|
| 46 |
|
| 47 |
-
print(f"📦 [DataManager V67.
|
| 48 |
|
| 49 |
async def initialize(self):
|
| 50 |
print(" > [DataManager] Starting initialization...")
|
|
@@ -121,7 +121,7 @@ class DataManager:
|
|
| 121 |
# ==================================================================
|
| 122 |
async def layer1_rapid_screening(self, adaptive_hub_ref=None) -> List[Dict[str, Any]]:
|
| 123 |
self.adaptive_hub_ref = adaptive_hub_ref
|
| 124 |
-
print(f"🔍 [Layer 1] Screening for High Vol Assets (
|
| 125 |
|
| 126 |
# 0. فحص صحة السوق أولاً
|
| 127 |
market_health = await self.check_global_market_health()
|
|
@@ -238,7 +238,7 @@ class DataManager:
|
|
| 238 |
return 0.5
|
| 239 |
|
| 240 |
# ==================================================================
|
| 241 |
-
# ⚖️ The Dual-Classifier Logic
|
| 242 |
# ==================================================================
|
| 243 |
def _classify_opportunity_type(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 244 |
try:
|
|
@@ -258,31 +258,40 @@ class DataManager:
|
|
| 258 |
upper_bb = curr['upper_bb'] if 'upper_bb' in curr else (curr['ema20'] + (2*curr['atr']))
|
| 259 |
bb_width = (upper_bb - lower_bb) / curr['ema20'] if curr['ema20'] > 0 else 1.0
|
| 260 |
|
| 261 |
-
# 🔥 1. Dead Coin Filter (
|
|
|
|
| 262 |
volatility_pct = (atr / close) * 100 if close > 0 else 0
|
| 263 |
-
if volatility_pct < 0.
|
| 264 |
|
| 265 |
-
# 🛡️ TYPE 1: SAFE_BOTTOM
|
| 266 |
-
|
|
|
|
| 267 |
dist_from_ema = (ema50 - close) / ema50
|
| 268 |
-
if close <= lower_bb * 1.
|
| 269 |
-
score = (
|
| 270 |
return {'type': 'SAFE_BOTTOM', 'score': min(score, 1.0)}
|
| 271 |
|
| 272 |
-
# 🔋 TYPE 2: ACCUMULATION_SQUEEZE
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
| 282 |
dist_to_upper = (upper_bb - close) / close
|
| 283 |
-
if dist_to_upper < 0.
|
| 284 |
score = rsi / 100.0
|
| 285 |
return {'type': 'MOMENTUM_LAUNCH', 'score': score}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
return {'type': 'NONE', 'score': 0}
|
| 288 |
|
|
|
|
| 1 |
# ============================================================
|
| 2 |
# 📂 ml_engine/data_manager.py
|
| 3 |
+
# (V67.3 - GEM-Architect: Full Code - Relaxed Funnel)
|
| 4 |
# ============================================================
|
| 5 |
|
| 6 |
import asyncio
|
|
|
|
| 44 |
'UP', 'DOWN', 'BEAR', 'BULL', '3S', '3L'
|
| 45 |
]
|
| 46 |
|
| 47 |
+
print(f"📦 [DataManager V67.3] Initialized (Relaxed Funnel).")
|
| 48 |
|
| 49 |
async def initialize(self):
|
| 50 |
print(" > [DataManager] Starting initialization...")
|
|
|
|
| 121 |
# ==================================================================
|
| 122 |
async def layer1_rapid_screening(self, adaptive_hub_ref=None) -> List[Dict[str, Any]]:
|
| 123 |
self.adaptive_hub_ref = adaptive_hub_ref
|
| 124 |
+
print(f"🔍 [Layer 1] Screening for High Vol Assets (Relaxed Funnel)...")
|
| 125 |
|
| 126 |
# 0. فحص صحة السوق أولاً
|
| 127 |
market_health = await self.check_global_market_health()
|
|
|
|
| 238 |
return 0.5
|
| 239 |
|
| 240 |
# ==================================================================
|
| 241 |
+
# ⚖️ The Dual-Classifier Logic (RELAXED FUNNEL)
|
| 242 |
# ==================================================================
|
| 243 |
def _classify_opportunity_type(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 244 |
try:
|
|
|
|
| 258 |
upper_bb = curr['upper_bb'] if 'upper_bb' in curr else (curr['ema20'] + (2*curr['atr']))
|
| 259 |
bb_width = (upper_bb - lower_bb) / curr['ema20'] if curr['ema20'] > 0 else 1.0
|
| 260 |
|
| 261 |
+
# 🔥 1. Dead Coin Filter (Relaxed to 0.3%)
|
| 262 |
+
# تم تخفيض العتبة من 0.4 إلى 0.3 للسماح للعملات الهادئة بالدخول إذا تحركت قليلاً
|
| 263 |
volatility_pct = (atr / close) * 100 if close > 0 else 0
|
| 264 |
+
if volatility_pct < 0.3: return {'type': 'NONE', 'score': 0}
|
| 265 |
|
| 266 |
+
# 🛡️ TYPE 1: SAFE_BOTTOM (Widened)
|
| 267 |
+
# RSI < 55 (كانت 45)، والسعر عند أو تحت الحد السفلي + 8% (كانت 5%)
|
| 268 |
+
if rsi < 55:
|
| 269 |
dist_from_ema = (ema50 - close) / ema50
|
| 270 |
+
if close <= lower_bb * 1.08:
|
| 271 |
+
score = (60 - rsi) / 20.0
|
| 272 |
return {'type': 'SAFE_BOTTOM', 'score': min(score, 1.0)}
|
| 273 |
|
| 274 |
+
# 🔋 TYPE 2: ACCUMULATION_SQUEEZE (Widened)
|
| 275 |
+
# RSI 40-65 (كانت 45-60)، BB Width < 0.18 (كانت 0.12)
|
| 276 |
+
elif 40 <= rsi <= 65:
|
| 277 |
+
if bb_width < 0.18:
|
| 278 |
+
# إزالة الشرط الصارم لـ EMA20 للسماح للنماذج بالاختيار
|
| 279 |
+
score = 1.0 - (bb_width * 3.0)
|
| 280 |
+
return {'type': 'ACCUMULATION_SQUEEZE', 'score': max(score, 0.5), 'is_squeeze': True}
|
| 281 |
+
|
| 282 |
+
# 🚀 TYPE 3: MOMENTUM_LAUNCH (Earlier Entry)
|
| 283 |
+
# RSI > 50 (كانت 60)
|
| 284 |
+
elif 50 < rsi < 85:
|
| 285 |
+
if close > ema50:
|
| 286 |
dist_to_upper = (upper_bb - close) / close
|
| 287 |
+
if dist_to_upper < 0.12: # السماح بمسافة أكبر قليلاً
|
| 288 |
score = rsi / 100.0
|
| 289 |
return {'type': 'MOMENTUM_LAUNCH', 'score': score}
|
| 290 |
+
|
| 291 |
+
# 🃏 Special Case: High Volatility Wildcard
|
| 292 |
+
# إذا كانت السيولة والتقلب مرتفعين جداً (> 1.5%)، مررها للنماذج
|
| 293 |
+
if volatility_pct > 1.5:
|
| 294 |
+
return {'type': 'SAFE_BOTTOM', 'score': 0.4}
|
| 295 |
|
| 296 |
return {'type': 'NONE', 'score': 0}
|
| 297 |
|