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

Update logging level from DEBUG to INFO in RiskCleanupManager for improved visibility of key operations and status checks.

Carles Sentis 1 hete
szülő
commit
6833b74da1
2 módosított fájl, 10 hozzáadás és 10 törlés
  1. 9 9
      src/monitoring/risk_cleanup_manager.py
  2. 1 1
      trading_bot.py

+ 9 - 9
src/monitoring/risk_cleanup_manager.py

@@ -43,7 +43,7 @@ class RiskCleanupManager:
             if not pending_sl_triggers:
                 return
 
-            logger.debug(f"Found {len(pending_sl_triggers)} pending SL triggers to check.")
+            logger.info(f"Found {len(pending_sl_triggers)} pending SL triggers to check.")
 
             for trigger_order in pending_sl_triggers:
                 symbol = trigger_order['symbol']
@@ -125,14 +125,14 @@ class RiskCleanupManager:
         """Check for automatic stop loss triggers based on Config.STOP_LOSS_PERCENTAGE as safety net."""
         try:
             if not getattr(Config, 'RISK_MANAGEMENT_ENABLED', True) or Config.STOP_LOSS_PERCENTAGE <= 0:
-                logger.debug(f"Risk management disabled or STOP_LOSS_PERCENTAGE <= 0 (value: {Config.STOP_LOSS_PERCENTAGE})")
+                logger.info(f"Risk management disabled or STOP_LOSS_PERCENTAGE <= 0 (value: {Config.STOP_LOSS_PERCENTAGE})")
                 return
 
             # Use DB positions for risk checks to ensure validated, up-to-date data
             stats = self.trading_engine.get_stats()
             positions = stats.get_open_positions() if stats else []
             if not positions:
-                logger.debug("No open positions found in DB for risk management check.")
+                logger.info("No open positions found in DB for risk management check.")
                 await self._cleanup_orphaned_stop_losses() # Call within class
                 return
 
@@ -146,10 +146,10 @@ class RiskCleanupManager:
                     roe_percentage = float(position.get('roe_percentage', 0))
 
                     if contracts == 0 or entry_price <= 0 or mark_price <= 0:
-                        logger.debug(f"Skipping position {symbol}: contracts={contracts}, entry_price={entry_price}, mark_price={mark_price}")
+                        logger.info(f"Skipping position {symbol}: contracts={contracts}, entry_price={entry_price}, mark_price={mark_price}")
                         continue
 
-                    logger.debug(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})")
 
                     if roe_percentage <= -Config.STOP_LOSS_PERCENTAGE:
                         token = symbol.split('/')[0] if '/' in symbol else symbol.split(':')[0]
@@ -232,7 +232,7 @@ Please close this position manually via /exit {token}"""
             if not pending_stop_losses:
                 return
 
-            logger.debug(f"Checking {len(pending_stop_losses)} pending stop losses for orphaned orders")
+            logger.info(f"Checking {len(pending_stop_losses)} pending stop losses for orphaned orders")
             current_positions = self.market_monitor_cache.cached_positions or [] 
             position_symbols = set()
             if current_positions:
@@ -455,7 +455,7 @@ Time: {datetime.now(timezone.utc).strftime('%H:%M:%S')}\\n\\n
             if not pending_sl_activation_orders:
                 return
 
-            logger.debug(f"Found {len(pending_sl_activation_orders)} 'pending_sl_activation' orders to check for cleanup.")
+            logger.info(f"Found {len(pending_sl_activation_orders)} 'pending_sl_activation' orders to check for cleanup.")
             
             # Get current open orders on the exchange from the cache
             open_exchange_orders_map = {
@@ -479,7 +479,7 @@ Time: {datetime.now(timezone.utc).strftime('%H:%M:%S')}\\n\\n
                 
                 # Condition 1: No active position for the symbol
                 if symbol in active_position_symbols:
-                    logger.debug(f"Pending SL (DB ID: {pending_sl_db_id}, Symbol: {symbol}) skipped: Active position exists.")
+                    logger.info(f"Pending SL (DB ID: {pending_sl_db_id}, Symbol: {symbol}) skipped: Active position exists.")
                     continue
 
                 # Condition 2: Parent entry order is no longer active on the exchange
@@ -491,7 +491,7 @@ Time: {datetime.now(timezone.utc).strftime('%H:%M:%S')}\\n\\n
                     if parent_exchange_order_id:
                         if parent_exchange_order_id in open_exchange_orders_map:
                             parent_order_active_on_exchange = True
-                            logger.debug(f"Pending SL (DB ID: {pending_sl_db_id}, Symbol: {symbol}) - Parent order {parent_bot_ref_id} (Exch ID: {parent_exchange_order_id}) is still active on exchange.")
+                            logger.info(f"Pending SL (DB ID: {pending_sl_db_id}, Symbol: {symbol}) - Parent order {parent_bot_ref_id} (Exch ID: {parent_exchange_order_id}) is still active on exchange.")
                         else:
                             logger.info(f"Pending SL (DB ID: {pending_sl_db_id}, Symbol: {symbol}) - Parent order {parent_bot_ref_id} (Exch ID: {parent_exchange_order_id}) NOT active on exchange.")
                     else:

+ 1 - 1
trading_bot.py

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