Skip to content

Commit 6639912

Browse files
author
Franz VETTER
committed
🔧 Fix: Correction DatabaseManager context dans OCO monitoring
❌ Problème résolu: - Erreur 'DatabaseManager object has no attribute conn' - Transactions de vente OCO non créées automatiquement ✅ Correction: - Utilisation correcte du context manager get_connection() - Vérification transaction existante avec with statement - Création automatique transaction vente lors exécution OCO 🎯 Impact: OCO monitoring 100% fonctionnel + transactions complètes
1 parent c833e70 commit 6639912

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/trading_engine.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,13 +837,14 @@ def _handle_oco_execution_direct(self, oco_order: Dict, executed_order: Dict, ex
837837

838838
# 2. 🔥 CRÉER LA TRANSACTION DE VENTE (BULLETPROOF)
839839
try:
840-
# Vérifier si la transaction existe déjà - MÉTHODE SQL DIRECTE
841-
cursor = self.database.conn.execute(
842-
"SELECT id FROM transactions WHERE order_id = ? AND order_side = 'SELL'",
843-
(order_id,)
844-
)
845-
existing_tx = cursor.fetchone()
846-
840+
# Vérifier si la transaction existe déjà - UTILISER LE CONTEXT MANAGER
841+
with self.database.get_connection() as conn:
842+
cursor = conn.execute(
843+
"SELECT id FROM transactions WHERE order_id = ? AND order_side = 'SELL'",
844+
(order_id,)
845+
)
846+
existing_tx = cursor.fetchone()
847+
847848
if existing_tx:
848849
self.logger.debug(f" ✅ Transaction vente déjà existante (ID: {existing_tx[0]})")
849850
else:

0 commit comments

Comments
 (0)