Riy777 commited on
Commit
d477f21
·
verified ·
1 Parent(s): e303919

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -19
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py (V14.4 - Production Fix & Detailed L2 Logging)
2
  import os
3
  import sys
4
  import traceback
@@ -57,7 +57,7 @@ async def initialize_system():
57
  if sys_state.ready:
58
  return
59
 
60
- print("\n🔌 [System V14.4] Starting Full Initialization Sequence...")
61
 
62
  try:
63
  # 1. البنية التحتية والبيانات (Infrastructure Layer)
@@ -166,8 +166,7 @@ async def _run_reanalysis_mode_full(open_trades):
166
  whale_data = await whale_monitor.get_symbol_whale_activity(symbol)
167
  news_text = await news_fetcher.get_news_for_symbol(symbol)
168
 
169
- # محاولة الحصول على درجة تيتان سريعة (إذا أمكن)
170
- # (يمكن تحسين هذا الجزء لاحقاً لاستدعاء تيتان فعلياً إذا توفرت الموارد)
171
  titan_score_now = 0.0
172
 
173
  current_data_packet = {
@@ -292,8 +291,13 @@ async def _run_explorer_mode_full():
292
 
293
  # بونص الأخبار (إضافة/خصم 10% بناءً على المشاعر)
294
  news_bonus = 0.0
295
- if news_score_raw > 0.25: news_bonus = 0.10
296
- elif news_score_raw < -0.25: news_bonus = -0.10
 
 
 
 
 
297
 
298
  final_l2_score = l1_score + whale_bonus + news_bonus
299
  # ضمان بقاء النتيجة بين 0 و 1
@@ -305,10 +309,12 @@ async def _run_explorer_mode_full():
305
  'whale_data': whale_data,
306
  'news_text': news_text,
307
  'news_score_raw': news_score_raw,
308
- # [LOGGING ADDITION] تخزين قيم البونص للشفافية
309
  'l2_bonuses': {
310
  'whale': whale_bonus,
311
- 'news': news_bonus
 
 
312
  }
313
  })
314
  l2_scored_candidates.append(cand)
@@ -324,24 +330,29 @@ async def _run_explorer_mode_full():
324
  # ----------------------------------------------------------------------
325
  print("\n--- 🧠 Layer 3: Omniscient Brain Validation ---")
326
 
327
- # 📝 [جديد V14.4] طباعة مفصلة لأسباب تأهل المرشحين (بما في ذلك بونص الحيتان والأخبار)
328
  if layer3_input_candidates:
329
  print("📋 [L3 Qualification] The following candidates are advancing to Omniscient Brain:")
330
- print(f" {'#':<3} {'SYMBOL':<10} | {'L1 Score':<8} | {'Whale Bonus':<11} | {'News Bonus':<10} | {'FINAL L2':<8}")
331
- print("-" * 65)
 
332
  for i, cand in enumerate(layer3_input_candidates, 1):
333
  l1 = cand.get('enhanced_final_score', 0)
334
  l2 = cand.get('layer2_score', 0)
335
  bonuses = cand.get('l2_bonuses', {})
 
 
 
336
  w_bonus = bonuses.get('whale', 0.0)
 
 
 
 
337
  n_bonus = bonuses.get('news', 0.0)
338
-
339
- # تنسيق الأرقام لتظهر كنسب مئوية مضافة (+15% مثلاً)
340
- w_str = f"+{w_bonus:.2f}" if w_bonus >= 0 else f"{w_bonus:.2f}"
341
- n_str = f"+{n_bonus:.2f}" if n_bonus >= 0 else f"{n_bonus:.2f}"
342
-
343
- print(f" #{i:<2} {cand['symbol']:<10} | {l1:.3f} | {w_str:<11} | {n_str:<10} | {l2:.3f}")
344
- print("-" * 65)
345
 
346
  approved_targets = []
347
  for cand in layer3_input_candidates:
@@ -388,7 +399,7 @@ async def lifespan(app: FastAPI):
388
  if data_manager: await data_manager.close()
389
  print("👋 [System] Shutdown complete.")
390
 
391
- app = FastAPI(lifespan=lifespan, title="Titan Hybrid System V14.4 (Production Fixes & Logging)")
392
 
393
  @app.get("/")
394
  async def root():
 
1
+ # app.py (V14.6 - Full Production Version & Enhanced Table Display)
2
  import os
3
  import sys
4
  import traceback
 
57
  if sys_state.ready:
58
  return
59
 
60
+ print("\n🔌 [System V14.6] Starting Full Initialization Sequence...")
61
 
62
  try:
63
  # 1. البنية التحتية والبيانات (Infrastructure Layer)
 
166
  whale_data = await whale_monitor.get_symbol_whale_activity(symbol)
167
  news_text = await news_fetcher.get_news_for_symbol(symbol)
168
 
169
+ # محاولة الحصول على درجة تيتان سريعة
 
170
  titan_score_now = 0.0
171
 
172
  current_data_packet = {
 
291
 
292
  # بونص الأخبار (إضافة/خصم 10% بناءً على المشاعر)
293
  news_bonus = 0.0
294
+ news_status = "NEUTRAL"
295
+ if news_score_raw > 0.25:
296
+ news_bonus = 0.10
297
+ news_status = "POSITIVE"
298
+ elif news_score_raw < -0.25:
299
+ news_bonus = -0.10
300
+ news_status = "NEGATIVE"
301
 
302
  final_l2_score = l1_score + whale_bonus + news_bonus
303
  # ضمان بقاء النتيجة بين 0 و 1
 
309
  'whale_data': whale_data,
310
  'news_text': news_text,
311
  'news_score_raw': news_score_raw,
312
+ # [LOGGING ADDITION] تخزين قيم البونص والتفاصيل للشفافية
313
  'l2_bonuses': {
314
  'whale': whale_bonus,
315
+ 'whale_signal': whale_signal,
316
+ 'news': news_bonus,
317
+ 'news_status': news_status
318
  }
319
  })
320
  l2_scored_candidates.append(cand)
 
330
  # ----------------------------------------------------------------------
331
  print("\n--- 🧠 Layer 3: Omniscient Brain Validation ---")
332
 
333
+ # 📝 [جديد V14.6] طباعة جدول مفصل يوضح أسباب تأهل المرشحين (نوع الأخبار وتأثير الحيتان)
334
  if layer3_input_candidates:
335
  print("📋 [L3 Qualification] The following candidates are advancing to Omniscient Brain:")
336
+ # رأس الجدول المحسن
337
+ print(f" {'#':<2} {'SYMBOL':<10} | {'L1':<6} | {'Whale Info':<16} | {'News Info':<16} | {'FINAL L2':<8}")
338
+ print("-" * 70)
339
  for i, cand in enumerate(layer3_input_candidates, 1):
340
  l1 = cand.get('enhanced_final_score', 0)
341
  l2 = cand.get('layer2_score', 0)
342
  bonuses = cand.get('l2_bonuses', {})
343
+
344
+ # تنسيق معلومات الحيتان
345
+ w_signal = bonuses.get('whale_signal', 'HOLD')
346
  w_bonus = bonuses.get('whale', 0.0)
347
+ w_info = f"{w_signal[:4]}.. ({w_bonus:+.2f})" if w_signal != 'HOLD' else "No Impact"
348
+
349
+ # تنسيق معلومات الأخبار
350
+ n_status = bonuses.get('news_status', 'NEUTRAL')
351
  n_bonus = bonuses.get('news', 0.0)
352
+ n_info = f"{n_status[:4]}.. ({n_bonus:+.2f})" if n_bonus != 0 else "Neutral"
353
+
354
+ print(f" #{i:<2} {cand['symbol']:<10} | {l1:.3f} | {w_info:<16} | {n_info:<16} | {l2:.3f}")
355
+ print("-" * 70)
 
 
 
356
 
357
  approved_targets = []
358
  for cand in layer3_input_candidates:
 
399
  if data_manager: await data_manager.close()
400
  print("👋 [System] Shutdown complete.")
401
 
402
+ app = FastAPI(lifespan=lifespan, title="Titan Hybrid System V14.6 (Full Production)")
403
 
404
  @app.get("/")
405
  async def root():