Jelajahi Sumber

Refactor position handling in RiskCleanupManager to remove redundant mark price checks. Updated logging to focus on contracts and entry price, enhancing clarity in skipped positions. This change improves the efficiency of risk management operations.

Carles Sentis 1 Minggu lalu
induk
melakukan
bb7394197f
2 mengubah file dengan 4 tambahan dan 6 penghapusan
  1. 3 5
      src/monitoring/risk_cleanup_manager.py
  2. 1 1
      trading_bot.py

+ 3 - 5
src/monitoring/risk_cleanup_manager.py

@@ -141,12 +141,11 @@ class RiskCleanupManager:
                     symbol = position.get('symbol', '')
                     contracts = float(position.get('current_position_size', 0))
                     entry_price = float(position.get('entry_price', 0))
-                    mark_price = float(position.get('mark_price', 0))
-                    unrealized_pnl = float(position.get('unrealized_pnl', 0))
                     roe_percentage = float(position.get('roe_percentage', 0))
+                    unrealized_pnl = float(position.get('unrealized_pnl', 0))
 
-                    if contracts == 0 or entry_price <= 0 or mark_price <= 0:
-                        logger.info(f"Skipping position {symbol}: contracts={contracts}, entry_price={entry_price}, mark_price={mark_price}")
+                    if contracts == 0 or entry_price <= 0:
+                        logger.info(f"Skipping position {symbol}: contracts={contracts}, entry_price={entry_price}")
                         continue
 
                     logger.info(f"[RiskMgmt] {symbol}: ROE={roe_percentage:+.2f}%, Threshold=-{Config.STOP_LOSS_PERCENTAGE}% (Trigger: {roe_percentage <= -Config.STOP_LOSS_PERCENTAGE})")
@@ -170,7 +169,6 @@ Token: {token}\\n
 Lifecycle ID: {lifecycle_id_str}\\n
 Position: {position_side} {abs(contracts):.6f}\\n
 Entry Price: ${entry_price:.4f}\\n
-Current Price: ${mark_price:.4f}\\n
 Unrealized P&L: ${unrealized_pnl:+.2f} ({roe_percentage:+.2f}% ROE)\\n
 Safety Threshold: -{Config.STOP_LOSS_PERCENTAGE}% ROE\\n
 Action: Executing emergency exit order..."""

+ 1 - 1
trading_bot.py

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