Bläddra i källkod

Update logic for largest_loss tracking in PerformanceCalculator and adjust SQL condition in AggregationManager. Largest loss is now initialized to 0 for better accuracy, and SQL query condition is modified to handle cases where largest losing cycle pnl is zero.

Carles Sentis 1 vecka sedan
förälder
incheckning
d4ae598ecd
3 ändrade filer med 4 tillägg och 4 borttagningar
  1. 1 1
      src/stats/aggregation_manager.py
  2. 2 2
      src/stats/performance_calculator.py
  3. 1 1
      trading_bot.py

+ 1 - 1
src/stats/aggregation_manager.py

@@ -111,7 +111,7 @@ class AggregationManager:
                         ELSE largest_winning_cycle_pnl
                     END,
                     largest_losing_cycle_pnl = CASE 
-                        WHEN ? < largest_losing_cycle_pnl THEN ?
+                        WHEN ? < largest_losing_cycle_pnl OR largest_losing_cycle_pnl = 0 THEN ?
                         ELSE largest_losing_cycle_pnl
                     END,
                     first_cycle_closed_at = CASE 

+ 2 - 2
src/stats/performance_calculator.py

@@ -62,7 +62,7 @@ class PerformanceCalculator:
             total_entry_volume = 0.0
             total_exit_volume = 0.0
             largest_win = 0.0
-            largest_loss = float('-inf')  # Initialize to negative infinity
+            largest_loss = 0.0  # Initialize to 0
             largest_win_token = "N/A"
             largest_loss_token = "N/A"
             largest_win_pct = 0.0
@@ -96,7 +96,7 @@ class PerformanceCalculator:
                         largest_win_pct = (token_largest_win / token.get('largest_winning_cycle_entry_volume', 1)) * 100
                     
                     # For losses, we want the most negative number
-                    if token_largest_loss < largest_loss:
+                    if token_largest_loss < 0 and (largest_loss == 0 or token_largest_loss < largest_loss):
                         largest_loss = token_largest_loss
                         largest_loss_token = token['token']
                         largest_loss_pct = (token_largest_loss / token.get('largest_losing_cycle_entry_volume', 1)) * 100

+ 1 - 1
trading_bot.py

@@ -14,7 +14,7 @@ from datetime import datetime
 from pathlib import Path
 
 # Bot version
-BOT_VERSION = "2.4.214"
+BOT_VERSION = "2.4.215"
 
 # Add src directory to Python path
 sys.path.insert(0, str(Path(__file__).parent / "src"))