Quellcode durchsuchen

Update bot version and adjust performance metrics to prioritize total P&L.

- Modified token performance ranking in info_commands to sort by Total P&L instead of ROE, providing clearer insights into overall profitability.
- Updated performance_calculator to reflect changes in sorting criteria, ensuring consistency in performance metrics across the application.
Carles Sentis vor 1 Woche
Ursprung
Commit
d3fdc2d8cc
3 geänderte Dateien mit 16 neuen und 15 gelöschten Zeilen
  1. 6 7
      src/commands/info_commands.py
  2. 9 7
      src/stats/performance_calculator.py
  3. 1 1
      trading_bot.py

+ 6 - 7
src/commands/info_commands.py

@@ -913,7 +913,7 @@ class InfoCommands:
         sorted_tokens = token_performance
         
         performance_text = "🏆 <b>Token Performance Ranking</b>\n"
-        performance_text += "<i>Ordered by ROE (Return on Equity)</i>\n\n"
+        performance_text += "<i>Ordered by Total P&L (Dollar Amount)</i>\n\n"
         
         # Add ranking with emojis
         for i, stats_data in enumerate(sorted_tokens, 1):
@@ -927,22 +927,21 @@ class InfoCommands:
             else:
                 rank_emoji = f"#{i}"
             
-            # Get ROE and P&L data
-            roe_percentage = stats_data.get('roe_percentage', 0)
             total_pnl = stats_data.get('total_realized_pnl', 0)
+            roe_percentage = stats_data.get('roe_percentage', 0)
             
-            # ROE emoji (primary metric)
+            # ROE emoji (shows performance efficiency)
             roe_emoji = "🟢" if roe_percentage >= 0 else "🔴"
             
-            # P&L emoji (secondary metric)
+            # P&L emoji (primary ranking metric)
             pnl_emoji = "🟢" if total_pnl >= 0 else "🔴"
             
             token_name = stats_data.get('token', 'N/A')
             completed_trades = stats_data.get('total_completed_cycles', 0)
             
-            # Format the line - emphasize ROE as primary metric
+            # Format the line - show both P&L (primary) and ROE (efficiency)
             performance_text += f"{rank_emoji} <b>{token_name}</b>\n"
-            performance_text += f"   {roe_emoji} ROE: {roe_percentage:+.2f}% | {pnl_emoji} P&L: ${total_pnl:,.2f}\n"
+            performance_text += f"   {pnl_emoji} P&L: ${total_pnl:,.2f} | {roe_emoji} ROE: {roe_percentage:+.2f}%\n"
             performance_text += f"   📊 Trades: {completed_trades}"
             
             # Add win rate if there are completed trades

+ 9 - 7
src/stats/performance_calculator.py

@@ -120,7 +120,7 @@ class PerformanceCalculator:
         initial_balance = float(self.db._get_metadata('initial_balance') or '0.0')
         roi_percentage = (total_realized_pnl / initial_balance * 100) if initial_balance > 0 else 0
 
-        # Calculate best and worst performing tokens
+        # Calculate best and worst performing tokens based on total P&L
         best_token_name = "N/A"
         best_token_pnl_pct = 0.0
         best_token_volume = 0.0
@@ -138,13 +138,15 @@ class PerformanceCalculator:
                 if entry_volume > 0:
                     pnl_pct = (total_pnl / entry_volume) * 100
                     
-                    if best_token_name == "N/A" or pnl_pct > best_token_pnl_pct:
+                    # Best token = highest total P&L
+                    if best_token_name == "N/A" or total_pnl > best_token_pnl_value:
                         best_token_name = token['token']
                         best_token_pnl_pct = pnl_pct
                         best_token_volume = entry_volume
                         best_token_pnl_value = total_pnl
                     
-                    if worst_token_name == "N/A" or pnl_pct < worst_token_pnl_pct:
+                    # Worst token = lowest total P&L
+                    if worst_token_name == "N/A" or total_pnl < worst_token_pnl_value:
                         worst_token_name = token['token']
                         worst_token_pnl_pct = pnl_pct
                         worst_token_volume = entry_volume
@@ -206,10 +208,10 @@ class PerformanceCalculator:
         }
 
     def get_token_performance(self, limit: int = 20) -> List[Dict[str, Any]]:
-        """Get performance stats by token, sorted by ROE (Return on Equity)."""
+        """Get performance stats by token, sorted by total P&L (dollar amount)."""
         formatter = get_formatter()
         
-        # Get all token stats first, then sort by ROE in Python
+        # Get all token stats first, then sort by total P&L in Python
         token_stats = self.db._fetch_query(
             "SELECT * FROM token_stats", 
             ()
@@ -240,10 +242,10 @@ class PerformanceCalculator:
             # Token display name (use token as-is)
             token['display_name'] = token['token'].upper()
         
-        # Sort by ROE percentage (highest to lowest), then by total PnL as tiebreaker
+        # Sort by total P&L (highest to lowest), then by ROE as tiebreaker
         sorted_tokens = sorted(
             token_stats,
-            key=lambda x: (x.get('roe_percentage', 0), x.get('total_realized_pnl', 0)),
+            key=lambda x: (x.get('total_realized_pnl', 0), x.get('roe_percentage', 0)),
             reverse=True
         )
         

+ 1 - 1
trading_bot.py

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