Ver Fonte

Refactor position data retrieval for improved accuracy

- Updated PositionsCommands to ensure exchange data is fetched before calculating ROE and mark price, enhancing the accuracy of position metrics.
- Improved code clarity by removing redundant exchange data retrieval, streamlining the data handling process.
Carles Sentis há 17 horas atrás
pai
commit
2cb25f20d8
2 ficheiros alterados com 4 adições e 2 exclusões
  1. 3 1
      src/commands/info/positions.py
  2. 1 1
      trading_bot.py

+ 3 - 1
src/commands/info/positions.py

@@ -99,6 +99,9 @@ class PositionsCommands(InfoCommandsBase):
                             logger.warning(f"Could not parse position_opened_at: {position_opened_at_str} for {symbol}")
                             duration_str = "Error"
                     
+                    # Get exchange data for this position (used for ROE and mark price)
+                    exchange_data = exchange_data_by_symbol.get(base_asset)
+                    
                     # Get price data with defaults - prioritize live exchange data
                     mark_price = entry_price  # Default to entry price
                     
@@ -125,7 +128,6 @@ class PositionsCommands(InfoCommandsBase):
                     
                     # Get ROE from live exchange data (much more accurate)
                     roe_percentage = 0.0
-                    exchange_data = exchange_data_by_symbol.get(base_asset)
                     if exchange_data and exchange_data.get('returnOnEquity') is not None:
                         try:
                             # Convert from decimal (0.118) to percentage (11.8%)

+ 1 - 1
trading_bot.py

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