Claude/switch branch 011 cv1v mm qct he vpbrjjs rz4#22
Conversation
Start ml1211
🔴 BUG CRITIQUE #1 - Filtre bookDepth manquant Fichier: core/scanner.py:128 Sévérité: CRITIQUE⚠️ Problème: - Paires avec bookDepth=0 pouvaient passer le filtre - Position ouverte avec depth=0 → slippage calculé = 0.00% - CAUSE RACINE du bug rapporté (logs: depth=0.0) Avant (ligne 127): ```python if math.isnan(spread) or spread <= 0.001 or spread > 0.02 or recent_volume < 100000 or balance_score < min: return 0.0 ``` Après (ligne 128): ```python if math.isnan(spread) or spread <= 0.001 or spread > 0.02 or book_depth <= 0 or recent_volume < 100000 or balance_score < min: return 0.0 ``` Impact: Garantit que TOUTES les positions auront depth > 0 pour calcul slippage valide --- 🟡 BUG #2 - Vérification bid_vol/ask_vol ambiguë Fichier: core/position_manager.py:694-696 Sévérité: MOYENNE Problème: ```python if bid_vol and ask_vol: # Faux si bid_vol=0 (0 est falsy) ``` Si bid_vol=0 et ask_vol=100: - Condition False alors que ask_vol existe - Utilise depth au lieu de volumes réels - Calcul slippage moins précis Correction: ```python if bid_vol is not None and ask_vol is not None: total_vol = bid_vol + ask_vol depth_factor = order_size / total_vol if total_vol > 0 else 0 ``` Impact: Utilise volumes réels même si un côté = 0 --- 📊 TESTS REQUIS: 1. Vérifier qu'aucune paire avec bookDepth=0 n'est dans top_pairs 2. Vérifier logs slippage: spread > 0 ET depth > 0 3. Ouvrir position → vérifier slippage != 0.00% ✅ Ces corrections résolvent définitivement le problème slippage=0.00%
Start ml1211
Bug #1: SL/TP distance affichait des valeurs négatives - frontend/src/lib/stores/position.js:17-28 - Problème: Pour LONG, SL distance était négative - Problème: Pour SHORT, TP distance était négative - Fix: Utiliser Math.abs() pour toujours afficher distance positive Bug #2: Profit Factor calculé avec formule totalement fausse - frontend/src/lib/stores/stats.js:92-107 - Ancienne formule FAUSSE: (wins × best_trade) / (losses × worst_trade) - Nouvelle formule CORRECTE: Σ(tous profits) / |Σ(toutes pertes)| - Le Profit Factor doit sommer TOUS les trades, pas juste best/worst
PR Compliance Guide 🔍(Compliance updated until commit ac666e3)Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label Previous compliance checksCompliance check up to commit 5a1ad46
|
||||||||||||||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
Bug #1: test_init_psycopg2_unavailable échouait - core/postgresql_datalogger.py:68 - Problème: Attribut 'pool' non initialisé quand psycopg2 indisponible - Fix: Ajouter `self.pool = None` avant le return Bugs #2-4: test_log_scan_error, test_log_market_context, test_log_trade - tests/test_postgresql_datalogger.py:188,213,258 - Problème: Tests attendaient 1 appel execute, mais code fait 2 appels (1 pour INSERT session, 1 pour INSERT table cible) - Fix: Changer de assert_called_once() à assert call_count == 2
PR Type
Bug fix
Description
Fix critical bookDepth filter bug preventing depth=0 pairs from being filtered
Fix bid_vol/ask_vol falsy check allowing zero values to bypass validation
Fix SL/TP distance calculations to use absolute values for correct display
Fix Profit Factor formula to sum all trades instead of using best/worst trades
Diagram Walkthrough
File Walkthrough
scanner.py
Add critical bookDepth validation filtercore/scanner.py
book_depth <= 0filter condition to prevent pairs with zerodepth from passing validation
slippage calculation
position_manager.py
Fix volume validation to handle zero valuescore/position_manager.py
if bid_vol and ask_vol) toexplicit None check (
if bid_vol is not None and ask_vol is not None)instead of falling back to depth
position.js
Use absolute values for distance calculationsfrontend/src/lib/stores/position.js
Math.abs()to ensure alwayspositive percentage
Math.abs()to ensure alwayspositive percentage
indicators
stats.js
Fix Profit Factor calculation to sum all tradesfrontend/src/lib/stores/stats.js
correct sum-based calculation
profit/loss summation
group separately