Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -144,8 +144,12 @@ def init_db():
|
|
| 144 |
async def save_to_db(data):
|
| 145 |
try:
|
| 146 |
with sqlite3.connect(DB_NAME) as conn:
|
| 147 |
-
conn.
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
init_db()
|
| 151 |
|
|
@@ -350,7 +354,7 @@ async def predict_signal(symbol, timeframe="1h"):
|
|
| 350 |
# ==========================================
|
| 351 |
db_task = (datetime.now(timezone.utc).isoformat(), symbol, timeframe, 'HAUSSIER' if final_p > 0.5 else 'BAISSIER',
|
| 352 |
final_p, prix, tp, sl, 'EN_COURS', regime_pred, time_prob, ml_prob, lstm_prob, p_sent)
|
| 353 |
-
|
| 354 |
|
| 355 |
print(f"✅ [VALIDÉ] {symbol} [{timeframe}] : Ordre envoyé au Juge.")
|
| 356 |
|
|
|
|
| 144 |
async def save_to_db(data):
|
| 145 |
try:
|
| 146 |
with sqlite3.connect(DB_NAME) as conn:
|
| 147 |
+
cursor = conn.cursor()
|
| 148 |
+
cursor.execute('INSERT INTO signals (date, symbol, timeframe, direction, prob, price, tp, sl, status, regime, prob_time, prob_ml, prob_lstm, prob_sent) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', data)
|
| 149 |
+
conn.commit() # 🛑 ON FORCE L'ÉCRITURE PHYSIQUE ICI
|
| 150 |
+
print(f"💾 Trade sauvegardé en DB : {data[1]} [{data[2]}]") # Petit log de confirmation
|
| 151 |
+
except Exception as e:
|
| 152 |
+
print(f"❌ DB Error (Erreur de Sauvegarde) : {e}")
|
| 153 |
|
| 154 |
init_db()
|
| 155 |
|
|
|
|
| 354 |
# ==========================================
|
| 355 |
db_task = (datetime.now(timezone.utc).isoformat(), symbol, timeframe, 'HAUSSIER' if final_p > 0.5 else 'BAISSIER',
|
| 356 |
final_p, prix, tp, sl, 'EN_COURS', regime_pred, time_prob, ml_prob, lstm_prob, p_sent)
|
| 357 |
+
await save_to_db(db_task)
|
| 358 |
|
| 359 |
print(f"✅ [VALIDÉ] {symbol} [{timeframe}] : Ordre envoyé au Juge.")
|
| 360 |
|