Start ml1211#25
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
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
…VpbrjjsRZ4 Claude/switch branch 011 cv1v mm qct he vpbrjjs rz4
|
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Compliance Guide 🔍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 |
||||||||||||||||||||||||||||
|
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Compliance Guide 🔍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 |
||||||||||||||||||||||||||||
|
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||
PR Type
Bug fix, Enhancement, Tests, Documentation
Description
PostgreSQL DataLogger robustness: Enhanced data serialization with safe type conversion, improved timezone handling using
timezone.utc, reduced batch intervals (batch_size: 50→10, flush_interval: 5.0→2.0s), and added comprehensive fallback chains for price and numeric value extractionScalability metrics integration: Added support for
recent_volume,vol5,vol15, andscalability_scoreacross datalogger, scanner loop, and database schema with corresponding SQL migrationData export and management: Implemented Excel export endpoint (
/api/datalogger/export/excel) and database reset endpoint (/api/datalogger/reset) with frontend UI controlsIndicator availability improvements: Fixed analyzer to return indicators and scores in rejection scenarios (swing structure absent, spread/orderbook rejection) instead of None/reason-only responses
Logging enhancements: Added
SimplePGLoggerfor ultra-simple direct PostgreSQL logging without batching, periodic flush task (30s interval), and comprehensive error handling with traceback informationBug fixes: Fixed timezone handling in position manager, book depth validation in scanner, profit factor calculation formula in frontend, SL/TP distance calculations using absolute values
Test updates: Corrected cursor execute call assertions to account for session initialization calls
Documentation: Added comprehensive guides for scalable parameters, database schema analysis, and diagnostic queries
Diagram Walkthrough
File Walkthrough
6 files
postgresql_datalogger.py
PostgreSQL DataLogger robustness improvements and data serializationfixescore/postgresql_datalogger.py
_extract_numeric_value()helper function to safely extractnumeric values from dicts or other types
serialize_config_safe()function to convertnon-JSON-serializable config objects (functions, datetime, Decimal,
custom objects) to JSON-safe formats
batch_sizefrom 50 to 10 andbatch_flush_intervalfrom5.0 to 2.0 seconds for more frequent flushing
timezone.utcfor alldatetime.now()calls to ensure PostgreSQL TIMESTAMPTZ compatibility
log_scan()with multiple fallbacks to extract price fromnested dicts and added validation to prevent NULL prices
recent_volume,vol5,vol15,scalability_score) in scan logginglog_opportunity()andlog_trade()with robust type checkingand numeric value extraction for all numeric fields
_batch_insert_scans()and_batch_insert_opportunities()withprice validation and fallback resolution for scan_id
informative debug messages
analyzer.py
Improve indicator availability in rejection scenarioscore/analyzer.py
indicators and scores instead of just reason
long_scoreandshort_scoreto the main indicators dictionary forfallback usage
instead of None
metadata instead of None
(removed 'reason' check filter)
indicators for all timeframes
position_manager.py
Fix timezone handling and improve setup monitoringcore/position_manager.py
timezoneimport for UTC timestamp handling_last_setupwith detailed bugtracking information
timezone.utcfor PostgreSQLTIMESTAMPTZ compatibility
serialize_config_safe()function calls for safe configurationserialization
config dictionaries
scanner.py
Add book depth validation to prevent slippage errorscore/scanner.py
book_depth <= 0to prevent invalidslippage calculations
bookDepth requirement
calculation
stats.js
Fix profit factor calculation formulafrontend/src/lib/stores/stats.js
absolute sum of losses
worst_trade) to correct formula
tradeHistoryinstead ofstatsfor accurateper-trade calculation
summing
scenarios
position.js
Fix SL and TP distance calculationsfrontend/src/lib/stores/position.js
slDistancecalculation to use absolute value for consistentpositive distance display
tpDistancecalculation to use absolute value for consistentpositive distance display
percentages
4 files
main.py
Enhanced PostgreSQL logging integration and data export capabilitiesmain.py
_simple_loggervariable for ultra-simple logging withoutbatch mode for debugging
scan_pair_for_setup()with priority-based indicatorextraction from
analysis_1mandanalysis_5mnested objectswith multiple price fallbacks and scalability metrics
seconds) to ensure timely data persistence
SimplePGLoggerinitialization ininit_instances()for simplifieddebugging logging
/api/datalogger/export/excelfor Excelexport and
/api/datalogger/resetfor database reset(
recent_volume,vol5,vol15,scalability_score)information
scanner_loop.py
Scanner loop PostgreSQL integration and data extraction improvementscore/callbacks/scanner_loop.py
get_pg_datalogger()to implement force initialization patternthat creates PostgreSQL DataLogger instance if not injected
SimplePGLoggerimport and global instance for simplified logginganalysis_1mandanalysis_5mnested objectsprevent NULL values in database
recent_volume,vol5,vol15,scalability_score) with aliases for compatibilitywith traceback information
_batch_insert_scans()and_batch_insert_opportunities()withrobust data validation
simple_pg_logger.py
Add simple PostgreSQL logger for scan datacore/simple_pg_logger.py
complexity
various data structures
rollback on errors
levels
VariablesPanel.svelte
Add Excel export and database reset functionalityfrontend/src/lib/components/VariablesPanel.svelte
exportingExcelandresettingDBfor trackingoperation status
exportExcel()function to download datalogger data asExcel file
resetDatabase()function with double confirmation forPostgreSQL data deletion
styling
.btn-exportand.btn-dangerbuttons with hovereffects
1 files
test_postgresql_datalogger.py
Correct test assertions for cursor execute callstests/test_postgresql_datalogger.py
test_log_scan_errorto expect 2 cursor.executecalls instead of 1
test_log_market_contextto expect 2 cursor.executecalls instead of 1
test_log_tradeto expect 2 cursor.execute callsinstead of 1
for actual operation)
2 files
apply_migration_scalability.ps1
Add PowerShell migration script for scalabilitydatabase/apply_migration_scalability.ps1
environment variable
output
indicators
migration_add_scalability_params.sql
Add scalability parameters to database schemadatabase/migration_add_scalability_params.sql
scan_logstable (recent_volume,vol5, vol15, scalability_score)
tradestable for entry/exit scalability parametersperformance
successfully
4 files
PARAMETRES_VARIABLES_SCAN_SCALABLES.md
Document scalable pair scan parametersPARAMETRES_VARIABLES_SCAN_SCALABLES.md
ANALYSE_PARAMETRES_SCAN_SCALABLES.md
Analyze scalable parameters against database schemaANALYSE_PARAMETRES_SCAN_SCALABLES.md
(recentVolume, vol5, vol15, score)
diagnostic_opportunities.sql
Add diagnostic queries for opportunities analysisdatabase/diagnostic_opportunities.sql
windows
opportunities table
distribution
COMPARAISON_PARAMETRES_SCALABLES_SCHEMA.md
Compare scalable parameters with database schemaCOMPARAISON_PARAMETRES_SCALABLES_SCHEMA.md
schema
table
score)
logged