Nexo-S commited on
Commit
2334f97
·
verified ·
1 Parent(s): 9d4d8a3

Update appp.py

Browse files
Files changed (1) hide show
  1. appp.py +27 -0
appp.py CHANGED
@@ -248,6 +248,16 @@ async def predict_signal(symbol, timeframe="1h"):
248
  risk_usd = CAPITAL_VIRTUEL * (risk_pct / 100)
249
  gain_estime_usd = risk_usd * (tp_m / sl_m)
250
 
 
 
 
 
 
 
 
 
 
 
251
  return {
252
  "symbol": symbol,
253
  "timeframe": timeframe,
@@ -327,6 +337,23 @@ async def run_judge_api():
327
  except Exception as e:
328
  return str(e)
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  # ================================
331
  # 🔌 SHUTDOWN SAFE
332
  # ================================
 
248
  risk_usd = CAPITAL_VIRTUEL * (risk_pct / 100)
249
  gain_estime_usd = risk_usd * (tp_m / sl_m)
250
 
251
+ db_task = (
252
+ datetime.now(timezone.utc).isoformat(),
253
+ symbol,
254
+ timeframe, # <-- LA NOUVELLE VARIABLE EST ICI
255
+ 'HAUSSIER' if final_p > 0.5 else 'BAISSIER',
256
+ float(final_p), float(price), float(tp), float(sl),
257
+ 'EN_COURS', regime, float(time_prob), float(ml_prob), float(lstm_prob), float(p_sent)
258
+ )
259
+ asyncio.create_task(save_to_db(db_task))
260
+
261
  return {
262
  "symbol": symbol,
263
  "timeframe": timeframe,
 
337
  except Exception as e:
338
  return str(e)
339
 
340
+ # --- FONCTION DE SAUVEGARDE DB ---
341
+ async def save_to_db(task):
342
+ try:
343
+ conn = sqlite3.connect("alphatrade_v9.db")
344
+ cur = conn.cursor()
345
+
346
+ # ⚠️ On a ajouté 'timeframe' juste après 'symbol' et un '?' en plus dans VALUES
347
+ cur.execute("""
348
+ INSERT INTO signals
349
+ (timestamp, symbol, timeframe, direction, prob, price, tp, sl, status, regime, prob_xgb, prob_rf, prob_lstm, prob_sent)
350
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
351
+ """, task)
352
+
353
+ conn.commit()
354
+ conn.close()
355
+ except Exception as e:
356
+ print(f"❌ Erreur DB: {e}")
357
  # ================================
358
  # 🔌 SHUTDOWN SAFE
359
  # ================================