Przeglądaj źródła

Increment BOT_VERSION to 2.2.145 and enhance RiskCleanupManager with shared state management.

- Updated BOT_VERSION for the upcoming release.
- Modified RiskCleanupManager to accept a shared_state parameter, allowing for centralized management of external stop losses.
- Initialized external_stop_losses within shared_state if not already present, improving data consistency and access.
Carles Sentis 2 dni temu
rodzic
commit
6da29b064e
2 zmienionych plików z 8 dodań i 3 usunięć
  1. 7 2
      src/monitoring/risk_cleanup_manager.py
  2. 1 1
      trading_bot.py

+ 7 - 2
src/monitoring/risk_cleanup_manager.py

@@ -14,11 +14,16 @@ from src.utils.token_display_formatter import get_formatter
 logger = logging.getLogger(__name__)
 
 class RiskCleanupManager:
-    def __init__(self, trading_engine, notification_manager, market_monitor_cache):
+    def __init__(self, trading_engine, notification_manager, market_monitor_cache, shared_state):
         self.trading_engine = trading_engine
         self.notification_manager = notification_manager
         self.market_monitor_cache = market_monitor_cache # To access cached orders/positions
-        self.external_stop_losses: Dict[str, Dict[str, Any]] = {} # exchange_order_id -> details
+        self.shared_state = shared_state # Store shared_state
+        # Initialize external_stop_losses within shared_state if it's not already there
+        if 'external_stop_losses' not in self.shared_state:
+            self.shared_state['external_stop_losses'] = {}
+        # For direct access if needed, though primary access should be via shared_state
+        self.external_stop_losses: Dict[str, Dict[str, Any]] = self.shared_state['external_stop_losses']
 
     # Methods like _check_automatic_risk_management, _cleanup_orphaned_stop_losses,
     # _check_external_stop_loss_orders, _cleanup_external_stop_loss_tracking,

+ 1 - 1
trading_bot.py

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