Browse Source

Increment bot version to 2.6.297 and improve logging in PositionTracker

- Updated BOT_VERSION to 2.6.297.
- Enhanced logging messages in PositionTracker to provide clearer warnings and information about position data retrieval and processing.
- Added sample position structure logging for better debugging and traceability of position handling.
Carles Sentis 1 week ago
parent
commit
0f8d4f26b9
2 changed files with 13 additions and 4 deletions
  1. 12 3
      src/monitoring/position_tracker.py
  2. 1 1
      trading_bot.py

+ 12 - 3
src/monitoring/position_tracker.py

@@ -151,20 +151,29 @@ class PositionTracker:
             positions = self.hl_client.get_positions()
             
             if not positions:
-                logger.debug("📊 No positions returned from exchange")
+                logger.warning("📊 No positions returned from exchange - this might be wrong if you have open positions!")
                 self.current_positions = {}
                 return
                 
-            logger.debug(f"📊 Processing {len(positions)} positions from exchange...")
+            logger.info(f"📊 Raw positions data from exchange: {len(positions)} positions")
+            # Log first position structure for debugging
+            if positions:
+                logger.info(f"📊 Sample position structure: {positions[0]}")
                 
+            logger.debug(f"📊 Processing {len(positions)} positions from exchange...")
+            
             new_positions = {}
-            for position in positions:
+            for i, position in enumerate(positions):
+                logger.debug(f"📊 Processing position {i+1}: {position}")
+                
                 # Access nested position data from info.position
                 position_data = position.get('info', {}).get('position', {})
                 if not position_data:
+                    logger.warning(f"📊 Position {i+1} has no info.position data: {position}")
                     continue
                     
                 size = float(position_data.get('szi', '0'))
+                logger.debug(f"📊 Position {i+1} size: {size}")
                 if size != 0:  # Only include open positions
                     symbol = position_data.get('coin', '')
                     if symbol:

+ 1 - 1
trading_bot.py

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