Riy777 commited on
Commit
155d67f
·
1 Parent(s): 1cc8695

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -10
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py (V15.11 - Fix LLM Reason Key + Deep MC Debugging)
2
  import os
3
  import sys
4
  import traceback
@@ -174,7 +174,7 @@ async def _analyze_symbol_task(symbol: str) -> Dict[str, Any]:
174
  return None
175
 
176
  # ==============================================================================
177
- # [ 🚀 🚀 🚀 ] الدورة الموحدة (النسخة النهائية V15.11)
178
  # ==============================================================================
179
  async def run_unified_cycle():
180
  """
@@ -273,7 +273,7 @@ async def run_unified_cycle():
273
 
274
  candidate['news_text'] = news_text
275
 
276
- # ج. مونت كارلو المتقدمة [ 🚀 تصحيح ومراقبة ]
277
  adv_mc_score = 0.0
278
  try:
279
  full_ohlcv_1h = await data_manager.get_latest_ohlcv(symbol, '1h', limit=100)
@@ -283,17 +283,30 @@ async def run_unified_cycle():
283
  else:
284
  mc_data = {'1h': full_ohlcv_1h}
285
  mc_res = await ml_processor.mc_analyzer.generate_1h_distribution_advanced(mc_data)
286
- if mc_res:
 
287
  prob_gain = mc_res.get('probability_of_gain', 0.5)
 
288
 
289
- # [ 🚀 ] طباعة لفهم سبب الدرجات الصفرية
290
- print(f" ℹ️ [MC Debug] {symbol}: Prob={prob_gain:.4f}")
291
 
 
 
 
 
 
 
292
  if prob_gain > 0.5:
293
- adv_mc_score = (prob_gain - 0.5) * 2 * 0.10
294
- if adv_mc_score > 0.10: adv_mc_score = 0.10
 
 
 
 
 
295
  except Exception as e:
296
- print(f" ⚠️ [MC Error] {symbol}: {e}")
297
 
298
  # --- د. حساب الدرجة النهائية ---
299
  final_score = l1_score + whale_score + news_score + adv_mc_score
@@ -385,7 +398,7 @@ async def run_unified_cycle():
385
  # ==============================================================================
386
  app = FastAPI(
387
  lifespan=lifespan,
388
- title="Titan V15.11 (Verbose Reason & MC Debug)",
389
  description="نظام تداول آلي هجين مع تعزيز رقمي L2"
390
  )
391
 
 
1
+ # app.py (V15.12 - Fix MC Logic & Restore Full Logging)
2
  import os
3
  import sys
4
  import traceback
 
174
  return None
175
 
176
  # ==============================================================================
177
+ # [ 🚀 🚀 🚀 ] الدورة الموحدة (النسخة النهائية V15.12 - MC Fixed)
178
  # ==============================================================================
179
  async def run_unified_cycle():
180
  """
 
273
 
274
  candidate['news_text'] = news_text
275
 
276
+ # ج. مونت كارلو المتقدمة [ 🚀 تصحيح المنطق V15.12 ]
277
  adv_mc_score = 0.0
278
  try:
279
  full_ohlcv_1h = await data_manager.get_latest_ohlcv(symbol, '1h', limit=100)
 
283
  else:
284
  mc_data = {'1h': full_ohlcv_1h}
285
  mc_res = await ml_processor.mc_analyzer.generate_1h_distribution_advanced(mc_data)
286
+
287
+ if mc_res and not mc_res.get('error', False):
288
  prob_gain = mc_res.get('probability_of_gain', 0.5)
289
+ model_name = mc_res.get('simulation_model', 'Unknown')
290
 
291
+ # طباعة للتتبع
292
+ print(f" ℹ️ [MC Info] {symbol} | Prob: {prob_gain:.2f} | Model: {model_name}")
293
 
294
+ # منطق الحساب الجديد:
295
+ # إذا كان الاحتمال أعلى من 50%، امنح نقاطاً.
296
+ # (prob - 0.5) * 0.20 يعني:
297
+ # 0.51 -> +0.002
298
+ # 0.60 -> +0.02
299
+ # 1.00 -> +0.10 (Max)
300
  if prob_gain > 0.5:
301
+ adv_mc_score = min(0.10, (prob_gain - 0.5) * 0.20)
302
+ else:
303
+ adv_mc_score = 0.0
304
+ else:
305
+ reason = mc_res.get('reason', 'Unknown Error') if mc_res else "Null Result"
306
+ print(f" ⚠️ [MC Warning] {symbol} skipped: {reason}")
307
+
308
  except Exception as e:
309
+ print(f" ⚠️ [MC Exception] {symbol}: {e}")
310
 
311
  # --- د. حساب الدرجة النهائية ---
312
  final_score = l1_score + whale_score + news_score + adv_mc_score
 
398
  # ==============================================================================
399
  app = FastAPI(
400
  lifespan=lifespan,
401
+ title="Titan V15.12 (Verbose Reason & MC Fixed)",
402
  description="نظام تداول آلي هجين مع تعزيز رقمي L2"
403
  )
404