Nexo-S commited on
Commit
1af8dac
·
verified ·
1 Parent(s): 73c29a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -859,7 +859,26 @@ def cancel_trade_api(trade_id):
859
  with sqlite3.connect(DB_NAME) as conn: conn.execute("UPDATE signals SET status = 'ANNULÉ 🗑️', confirmed = 0 WHERE id = ?", (int(trade_id),)); conn.commit()
860
  return {"status": "success"}
861
  except: return {"status": "error"}
862
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863
 
864
  def training_wrapper(symbol, *args): return trigger_training(str(symbol).strip().upper() if isinstance(symbol, str) else "BTC/USD")
865
  def force_scalping_mode():
@@ -872,6 +891,11 @@ def force_scalping_mode():
872
  with gr.Blocks(theme=gr.themes.Monochrome()) as iface:
873
  gr.Markdown("# 🦖 Alpha V30 Dinosaur Engine (Master Edition)")
874
  with gr.Tab("Admin"): gr.Button("Forcer Entraînement", variant="stop").click(fn=training_wrapper, inputs=gr.Textbox(label="Symbole à recalibrer", value="BTC/USDT"), outputs=gr.Textbox(), api_name="trigger_training")
 
 
 
 
 
875
  with gr.Tab("🎯 Prédictions"): gr.Button("Predict", variant="primary").click(fn=predict_signal, inputs=[gr.Textbox(label="Symbole", value="BTC/USD"), gr.Dropdown(choices=["1m", "5m", "15m", "1h"], value="1h")], outputs=gr.JSON())
876
  with gr.Tab("⚖️ Système"):
877
  gr.Button("Judge").click(fn=run_judge_api, inputs=gr.Textbox(value="{}", visible=False), outputs=gr.JSON(), api_name="run_judge_api")
 
859
  with sqlite3.connect(DB_NAME) as conn: conn.execute("UPDATE signals SET status = 'ANNULÉ 🗑️', confirmed = 0 WHERE id = ?", (int(trade_id),)); conn.commit()
860
  return {"status": "success"}
861
  except: return {"status": "error"}
862
+ def reset_trade_history():
863
+ """
864
+ Supprime UNIQUEMENT les trades (la table signals)
865
+ Garde intacte la mémoire génétique (la table agents)
866
+ """
867
+ try:
868
+ with sqlite3.connect(DB_NAME, timeout=10) as conn:
869
+ cursor = conn.cursor()
870
+
871
+ # 1. On supprime tout l'historique des trades (brouillons, validés, expirés...)
872
+ cursor.execute("DELETE FROM signals")
873
+
874
+ # 2. (Optionnel mais propre) On remet le compteur d'ID à 1
875
+ cursor.execute("DELETE FROM sqlite_sequence WHERE name='signals'")
876
+
877
+ conn.commit()
878
+
879
+ return "✅ RESET RÉUSSI : Tous les trades ont été effacés. L'ADN est conservé !"
880
+ except Exception as e:
881
+ return f"❌ ERREUR RESET : {e}"
882
 
883
  def training_wrapper(symbol, *args): return trigger_training(str(symbol).strip().upper() if isinstance(symbol, str) else "BTC/USD")
884
  def force_scalping_mode():
 
891
  with gr.Blocks(theme=gr.themes.Monochrome()) as iface:
892
  gr.Markdown("# 🦖 Alpha V30 Dinosaur Engine (Master Edition)")
893
  with gr.Tab("Admin"): gr.Button("Forcer Entraînement", variant="stop").click(fn=training_wrapper, inputs=gr.Textbox(label="Symbole à recalibrer", value="BTC/USDT"), outputs=gr.Textbox(), api_name="trigger_training")
894
+ gr.Markdown("---")
895
+ gr.Markdown("### ⚠️ Zone de Danger")
896
+ reset_btn = gr.Button("🗑️ Purger tous les trades (Garder l'ADN)", variant="primary")
897
+ reset_out = gr.Textbox(label="Résultat du nettoyage")
898
+ reset_btn.click(fn=reset_trade_history, inputs=[], outputs=reset_out, api_name="reset_trades")
899
  with gr.Tab("🎯 Prédictions"): gr.Button("Predict", variant="primary").click(fn=predict_signal, inputs=[gr.Textbox(label="Symbole", value="BTC/USD"), gr.Dropdown(choices=["1m", "5m", "15m", "1h"], value="1h")], outputs=gr.JSON())
900
  with gr.Tab("⚖️ Système"):
901
  gr.Button("Judge").click(fn=run_judge_api, inputs=gr.Textbox(value="{}", visible=False), outputs=gr.JSON(), api_name="run_judge_api")