Riy777 commited on
Commit
74212d2
ยท
verified ยท
1 Parent(s): c57dd8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -1,5 +1,5 @@
1
  # ==============================================================================
2
- # ๐Ÿš€ app.py (V61.2 - GEM-Architect: Full Diagnostics Restored)
3
  # ==============================================================================
4
 
5
  import os
@@ -182,7 +182,7 @@ async def auto_pilot_loop():
182
  async def lifespan(app: FastAPI):
183
  global r2, data_manager, ml_processor, adaptive_hub, trade_manager, whale_monitor, news_fetcher, senti_analyzer, sys_state, scheduler
184
 
185
- logger.info("\n๐Ÿš€ [System] Startup Sequence (Titan V61.2 - Full Diagnostics)...")
186
  try:
187
  r2 = R2Service()
188
  data_manager = DataManager(contracts_db={}, whale_monitor=None, r2_service=r2)
@@ -256,14 +256,13 @@ async def _analyze_symbol_task(candidate_data: Dict[str, Any]) -> Dict[str, Any]
256
  'dynamic_limits': candidate_data.get('dynamic_limits', {}),
257
  'asset_regime': candidate_data.get('asset_regime', 'UNKNOWN'),
258
  'strategy_tag': candidate_data.get('strategy_tag', 'NONE'),
259
- 'strategy_type': candidate_data.get('strategy_type', 'NORMAL'), # Passing Type
260
  'l1_score': candidate_data.get('l1_sort_score', 0)
261
  }
262
 
263
  res = await ml_processor.process_compound_signal(raw_data)
264
  if not res: return None
265
 
266
- # Pass Type Forward
267
  res['strategy_type'] = candidate_data.get('strategy_type', 'NORMAL')
268
  return res
269
  except Exception: return None
@@ -360,7 +359,7 @@ async def run_unified_cycle():
360
 
361
  approved_signals = []
362
 
363
- # โœ… FIX: ุฅุนุงุฏุฉ ุนุฑุถ ุงู„ุฌุฏูˆู„ ุงู„ุชูุตูŠู„ูŠ ูƒุงู…ู„ุงู‹ ู…ุน ุฅุถุงูุฉ ุงู„ุนู…ูˆุฏ ุงู„ุฌุฏูŠุฏ (TYPE)
364
  header = (f"{'SYM':<9} | {'TYPE':<10} | {'L2':<5} | {'TITAN':<5} | {'PATT':<5} | "
365
  f"{'WHALE':<6} | {'MC(A)':<6} | {'FINAL':<6} | {'ORACLE':<6} | {'STATUS'}")
366
 
@@ -647,7 +646,8 @@ async def check_live_pnl_and_status(selected_view="Dual-Core (Hybrid)"):
647
 
648
  metrics = scheduler.get_status_metrics() if scheduler else {}
649
  sch_w_time = metrics.get("weekly_timer", "Wait")
650
- sch_w_cnt = metrics.get("weekly_count", 0)
 
651
 
652
  neural_md = f"""
653
  <div style='background-color: #1a1a1a; padding: 10px; border-radius: 8px; border: 1px solid #333; font-size: 12px; margin-top: 10px;'>
@@ -661,6 +661,10 @@ async def check_live_pnl_and_status(selected_view="Dual-Core (Hybrid)"):
661
  <td style='padding:4px 0;'>๐Ÿ“… Weekly Tune:</td>
662
  <td style='text-align:right; color:#fff;'>{sch_w_time}</td>
663
  </tr>
 
 
 
 
664
  </table>
665
  </div>
666
  """
@@ -679,7 +683,7 @@ async def check_live_pnl_and_status(selected_view="Dual-Core (Hybrid)"):
679
 
680
  diag_df = pd.DataFrame(diag_list, columns=["Model", "Wins", "Losses", "PnL (USD)"])
681
 
682
- # โœ… NEW: Type Stats DataFrame
683
  type_stats_list = []
684
  if trade_manager and hasattr(trade_manager, 'type_stats'):
685
  for t_name, t_data in trade_manager.type_stats.items():
@@ -688,8 +692,6 @@ async def check_live_pnl_and_status(selected_view="Dual-Core (Hybrid)"):
688
  losses = t_data.get('losses', 0)
689
  prof = t_data.get('profit_usd', 0.0)
690
  loss_val = t_data.get('loss_usd', 0.0)
691
-
692
- # Format: +$Profit / -$Loss
693
  profitability_html = format_pnl_split(prof, loss_val)
694
  type_stats_list.append([name_clean, wins, losses, profitability_html])
695
 
@@ -744,10 +746,10 @@ async def check_live_pnl_and_status(selected_view="Dual-Core (Hybrid)"):
744
  def create_gradio_ui():
745
  custom_css = ".gradio-container {background:#0b0f19} .dataframe {background:#1a1a1a!important} .html-box {min-height:180px}"
746
 
747
- with gr.Blocks(title="Titan V61.2 (Dual-Type Dashboard)") as demo:
748
  gr.HTML(f"<style>{custom_css}</style>")
749
 
750
- gr.Markdown("# ๐Ÿš€ Titan V61.2 (Cybernetic: Dual-Type Engine)")
751
 
752
  with gr.Row():
753
  with gr.Column(scale=3):
@@ -764,7 +766,7 @@ def create_gradio_ui():
764
  wallet_out = gr.HTML(label="Smart Wallet", elem_classes="html-box")
765
  neural_out = gr.HTML(label="Neural Cycles", elem_classes="html-box")
766
 
767
- # โœ… NEW: Type Stats Table
768
  gr.Markdown("### ๐Ÿ’Ž Opportunity Types")
769
  type_stats_out = gr.Dataframe(
770
  headers=["Coin Type", "Wins", "Losses", "Profitability"],
@@ -829,7 +831,6 @@ def create_gradio_ui():
829
  btn_reset_diag.click(fn=reset_diagnostics_handler, outputs=alert)
830
  btn_reset_guard.click(fn=reset_guardians_handler, outputs=alert)
831
 
832
- # Added type_stats_out to outputs
833
  gr.Timer(3).tick(fn=check_live_pnl_and_status, inputs=stats_dd,
834
  outputs=[logs, status, live_chart, t_price, t_entry, t_tp, t_sl, t_pnl, watchlist_out, diagnostic_out, type_stats_out, wallet_out, history_out, neural_out])
835
  return demo
 
1
  # ==============================================================================
2
+ # ๐Ÿš€ app.py (V61.3 - GEM-Architect: Full Neural Dashboard Restored)
3
  # ==============================================================================
4
 
5
  import os
 
182
  async def lifespan(app: FastAPI):
183
  global r2, data_manager, ml_processor, adaptive_hub, trade_manager, whale_monitor, news_fetcher, senti_analyzer, sys_state, scheduler
184
 
185
+ logger.info("\n๐Ÿš€ [System] Startup Sequence (Titan V61.3 - Full Check)...")
186
  try:
187
  r2 = R2Service()
188
  data_manager = DataManager(contracts_db={}, whale_monitor=None, r2_service=r2)
 
256
  'dynamic_limits': candidate_data.get('dynamic_limits', {}),
257
  'asset_regime': candidate_data.get('asset_regime', 'UNKNOWN'),
258
  'strategy_tag': candidate_data.get('strategy_tag', 'NONE'),
259
+ 'strategy_type': candidate_data.get('strategy_type', 'NORMAL'),
260
  'l1_score': candidate_data.get('l1_sort_score', 0)
261
  }
262
 
263
  res = await ml_processor.process_compound_signal(raw_data)
264
  if not res: return None
265
 
 
266
  res['strategy_type'] = candidate_data.get('strategy_type', 'NORMAL')
267
  return res
268
  except Exception: return None
 
359
 
360
  approved_signals = []
361
 
362
+ # โœ… TABLE HEADER UPDATED
363
  header = (f"{'SYM':<9} | {'TYPE':<10} | {'L2':<5} | {'TITAN':<5} | {'PATT':<5} | "
364
  f"{'WHALE':<6} | {'MC(A)':<6} | {'FINAL':<6} | {'ORACLE':<6} | {'STATUS'}")
365
 
 
646
 
647
  metrics = scheduler.get_status_metrics() if scheduler else {}
648
  sch_w_time = metrics.get("weekly_timer", "Wait")
649
+ # โœ… RESTORED MONTHLY METRICS
650
+ sch_m_time = metrics.get("monthly_timer", "Wait")
651
 
652
  neural_md = f"""
653
  <div style='background-color: #1a1a1a; padding: 10px; border-radius: 8px; border: 1px solid #333; font-size: 12px; margin-top: 10px;'>
 
661
  <td style='padding:4px 0;'>๐Ÿ“… Weekly Tune:</td>
662
  <td style='text-align:right; color:#fff;'>{sch_w_time}</td>
663
  </tr>
664
+ <tr>
665
+ <td style='padding:4px 0;'>๐Ÿ—“๏ธ Monthly Evo:</td>
666
+ <td style='text-align:right; color:#fff;'>{sch_m_time}</td>
667
+ </tr>
668
  </table>
669
  </div>
670
  """
 
683
 
684
  diag_df = pd.DataFrame(diag_list, columns=["Model", "Wins", "Losses", "PnL (USD)"])
685
 
686
+ # Type Stats DataFrame
687
  type_stats_list = []
688
  if trade_manager and hasattr(trade_manager, 'type_stats'):
689
  for t_name, t_data in trade_manager.type_stats.items():
 
692
  losses = t_data.get('losses', 0)
693
  prof = t_data.get('profit_usd', 0.0)
694
  loss_val = t_data.get('loss_usd', 0.0)
 
 
695
  profitability_html = format_pnl_split(prof, loss_val)
696
  type_stats_list.append([name_clean, wins, losses, profitability_html])
697
 
 
746
  def create_gradio_ui():
747
  custom_css = ".gradio-container {background:#0b0f19} .dataframe {background:#1a1a1a!important} .html-box {min-height:180px}"
748
 
749
+ with gr.Blocks(title="Titan V61.3 (Full Neural Dashboard)") as demo:
750
  gr.HTML(f"<style>{custom_css}</style>")
751
 
752
+ gr.Markdown("# ๐Ÿš€ Titan V61.3 (Cybernetic: Dual-Type Engine)")
753
 
754
  with gr.Row():
755
  with gr.Column(scale=3):
 
766
  wallet_out = gr.HTML(label="Smart Wallet", elem_classes="html-box")
767
  neural_out = gr.HTML(label="Neural Cycles", elem_classes="html-box")
768
 
769
+ # Type Stats Table
770
  gr.Markdown("### ๐Ÿ’Ž Opportunity Types")
771
  type_stats_out = gr.Dataframe(
772
  headers=["Coin Type", "Wins", "Losses", "Profitability"],
 
831
  btn_reset_diag.click(fn=reset_diagnostics_handler, outputs=alert)
832
  btn_reset_guard.click(fn=reset_guardians_handler, outputs=alert)
833
 
 
834
  gr.Timer(3).tick(fn=check_live_pnl_and_status, inputs=stats_dd,
835
  outputs=[logs, status, live_chart, t_price, t_entry, t_tp, t_sl, t_pnl, watchlist_out, diagnostic_out, type_stats_out, wallet_out, history_out, neural_out])
836
  return demo