Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# app.py (V17.
|
| 2 |
import os
|
| 3 |
import sys
|
| 4 |
import traceback
|
|
@@ -189,7 +189,7 @@ async def _analyze_symbol_task(symbol: str) -> Dict[str, Any]:
|
|
| 189 |
# ==============================================================================
|
| 190 |
# [ 🚀 🚀 🚀 ] الدورة الموحدة (النسخة الكاملة V15.17 - Batch Selection)
|
| 191 |
# ==============================================================================
|
| 192 |
-
#
|
| 193 |
async def run_unified_cycle():
|
| 194 |
"""
|
| 195 |
دورة التحليل الكاملة: L1 -> L2 -> L3 (Oracle) -> L4 (Sniper Batch).
|
|
@@ -437,7 +437,7 @@ async def check_live_pnl_and_status():
|
|
| 437 |
watch_count = len(trade_manager.watchlist)
|
| 438 |
status_md = f"""
|
| 439 |
**الحالة:** {'<span style="color:green;">جاهز</span>' if not sys_state.cycle_running else '<span style="color:orange;">تحليل...</span>'} |
|
| 440 |
-
**الصفقات
|
| 441 |
**قائمة المراقبة:** {watch_count}
|
| 442 |
"""
|
| 443 |
|
|
@@ -558,9 +558,6 @@ def create_gradio_ui():
|
|
| 558 |
run_cycle_btn = gr.Button("🚀 (1) بدء دورة التحليل يدوياً")
|
| 559 |
gr.Markdown("## 📝 حالة النظام")
|
| 560 |
status_markdown = gr.Markdown(f"**الحالة:** {'جاري التهيئة...' if not sys_state.ready else 'جاهز'}")
|
| 561 |
-
|
| 562 |
-
# [ 💡💡💡 هذا هو الإصلاح 💡💡💡 ]
|
| 563 |
-
# (إزالة 'height=300')
|
| 564 |
watchlist_output = gr.DataFrame(label="قائمة المراقبة (Watchlist)")
|
| 565 |
|
| 566 |
with gr.Column(scale=3):
|
|
@@ -583,13 +580,25 @@ def create_gradio_ui():
|
|
| 583 |
api_name="run_cycle_manual" # (يمكن استدعاؤها كـ API أيضاً)
|
| 584 |
)
|
| 585 |
|
| 586 |
-
# 2. التحديث التلقائي (كل 15 ثانية)
|
|
|
|
|
|
|
| 587 |
demo.load(
|
| 588 |
fn=check_live_pnl_and_status,
|
| 589 |
inputs=None,
|
| 590 |
-
outputs=[cycle_logs_output, status_markdown, live_symbol, live_pnl, live_details, live_chart, watchlist_output]
|
| 591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
)
|
|
|
|
| 593 |
return demo
|
| 594 |
|
| 595 |
# --- [ 💡 الأهم: دمج التطبيقين 💡 ] ---
|
|
|
|
| 1 |
+
# app.py (V17.3 - FastAPI Core + Gradio UI - Timer Tick Fix)
|
| 2 |
import os
|
| 3 |
import sys
|
| 4 |
import traceback
|
|
|
|
| 189 |
# ==============================================================================
|
| 190 |
# [ 🚀 🚀 🚀 ] الدورة الموحدة (النسخة الكاملة V15.17 - Batch Selection)
|
| 191 |
# ==============================================================================
|
| 192 |
+
# (دالة run_unified_cycle تبقى كما هي 100%)
|
| 193 |
async def run_unified_cycle():
|
| 194 |
"""
|
| 195 |
دورة التحليل الكاملة: L1 -> L2 -> L3 (Oracle) -> L4 (Sniper Batch).
|
|
|
|
| 437 |
watch_count = len(trade_manager.watchlist)
|
| 438 |
status_md = f"""
|
| 439 |
**الحالة:** {'<span style="color:green;">جاهز</span>' if not sys_state.cycle_running else '<span style="color:orange;">تحليل...</span>'} |
|
| 440 |
+
**الصفقات الموفتوحة:** {trade_count} |
|
| 441 |
**قائمة المراقبة:** {watch_count}
|
| 442 |
"""
|
| 443 |
|
|
|
|
| 558 |
run_cycle_btn = gr.Button("🚀 (1) بدء دورة التحليل يدوياً")
|
| 559 |
gr.Markdown("## 📝 حالة النظام")
|
| 560 |
status_markdown = gr.Markdown(f"**الحالة:** {'جاري التهيئة...' if not sys_state.ready else 'جاهز'}")
|
|
|
|
|
|
|
|
|
|
| 561 |
watchlist_output = gr.DataFrame(label="قائمة المراقبة (Watchlist)")
|
| 562 |
|
| 563 |
with gr.Column(scale=3):
|
|
|
|
| 580 |
api_name="run_cycle_manual" # (يمكن استدعاؤها كـ API أيضاً)
|
| 581 |
)
|
| 582 |
|
| 583 |
+
# 2. التحديث التلقائي (كل 15 ثانية) - [ 💡💡💡 هذا هو الإصلاح 💡💡💡 ]
|
| 584 |
+
|
| 585 |
+
# (أ) تحميل البيانات مرة واحدة عند فتح الصفحة
|
| 586 |
demo.load(
|
| 587 |
fn=check_live_pnl_and_status,
|
| 588 |
inputs=None,
|
| 589 |
+
outputs=[cycle_logs_output, status_markdown, live_symbol, live_pnl, live_details, live_chart, watchlist_output]
|
| 590 |
+
)
|
| 591 |
+
|
| 592 |
+
# (ب) إنشاء مشغل مخفي يعمل كل 15 ثانية
|
| 593 |
+
timer = gr.Timer(15)
|
| 594 |
+
|
| 595 |
+
# (ج) ربط المشغل بالدالة
|
| 596 |
+
timer.tick(
|
| 597 |
+
fn=check_live_pnl_and_status,
|
| 598 |
+
inputs=None,
|
| 599 |
+
outputs=[cycle_logs_output, status_markdown, live_symbol, live_pnl, live_details, live_chart, watchlist_output]
|
| 600 |
)
|
| 601 |
+
|
| 602 |
return demo
|
| 603 |
|
| 604 |
# --- [ 💡 الأهم: دمج التطبيقين 💡 ] ---
|