Forráskód Böngészése

Enhance SimplePositionTracker to include unrealized P&L and ROE percentage in position updates. This improves the clarity of financial data presented to users, aligning with recent updates for consistent data handling across the application.

Carles Sentis 1 hete
szülő
commit
e50648a320
2 módosított fájl, 8 hozzáadás és 3 törlés
  1. 7 2
      src/monitoring/simple_position_tracker.py
  2. 1 1
      trading_bot.py

+ 7 - 2
src/monitoring/simple_position_tracker.py

@@ -126,7 +126,9 @@ class SimplePositionTracker:
                     lifecycle_id=lifecycle_id,
                     entry_price=entry_price,
                     entry_amount=size,
-                    exchange_fill_id=f"position_detected_{timestamp.isoformat()}"
+                    exchange_fill_id=f"position_detected_{timestamp.isoformat()}",
+                    unrealized_pnl=exchange_pos.get('unrealizedPnl'),
+                    unrealized_pnl_percentage=exchange_pos.get('returnOnEquity', 0.0) * 100  # Convert to percentage
                 )
                 
                 if success:
@@ -242,7 +244,10 @@ class SimplePositionTracker:
             
             # Update position size using existing manager
             success = stats.trade_manager.update_trade_market_data(
-                lifecycle_id, current_position_size=exchange_size
+                lifecycle_id, 
+                current_position_size=exchange_size,
+                unrealized_pnl=exchange_pos.get('unrealizedPnl'),
+                unrealized_pnl_percentage=exchange_pos.get('returnOnEquity', 0.0) * 100  # Convert to percentage
             )
             
             if success:

+ 1 - 1
trading_bot.py

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