浏览代码

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 月之前
父节点
当前提交
bb7394197f
共有 2 个文件被更改,包括 4 次插入6 次删除
  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', '')
                     symbol = position.get('symbol', '')
                     contracts = float(position.get('current_position_size', 0))
                     contracts = float(position.get('current_position_size', 0))
                     entry_price = float(position.get('entry_price', 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))
                     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
                         continue
 
 
                     logger.info(f"[RiskMgmt] {symbol}: ROE={roe_percentage:+.2f}%, Threshold=-{Config.STOP_LOSS_PERCENTAGE}% (Trigger: {roe_percentage <= -Config.STOP_LOSS_PERCENTAGE})")
                     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
 Lifecycle ID: {lifecycle_id_str}\\n
 Position: {position_side} {abs(contracts):.6f}\\n
 Position: {position_side} {abs(contracts):.6f}\\n
 Entry Price: ${entry_price:.4f}\\n
 Entry Price: ${entry_price:.4f}\\n
-Current Price: ${mark_price:.4f}\\n
 Unrealized P&L: ${unrealized_pnl:+.2f} ({roe_percentage:+.2f}% ROE)\\n
 Unrealized P&L: ${unrealized_pnl:+.2f} ({roe_percentage:+.2f}% ROE)\\n
 Safety Threshold: -{Config.STOP_LOSS_PERCENTAGE}% ROE\\n
 Safety Threshold: -{Config.STOP_LOSS_PERCENTAGE}% ROE\\n
 Action: Executing emergency exit order..."""
 Action: Executing emergency exit order..."""

+ 1 - 1
trading_bot.py

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