use enhanced orchestrator

This commit is contained in:
Dobromir Popov
2025-06-25 03:42:00 +03:00
parent 120f3f558c
commit d4d3c75514
7 changed files with 58 additions and 14 deletions

View File

@ -33,6 +33,11 @@ how effective is our training? show current loss and accuracy on the chart. also
what are our rewards and penalties in the RL training pipeline? reprt them so we can evaluate them and make sure they are working as expected and do improvements what are our rewards and penalties in the RL training pipeline? reprt them so we can evaluate them and make sure they are working as expected and do improvements
allow models to be dynamically loaded and unloaded from the webui (orchestrator)
show cob data in the dashboard over ws
report and audit rewards and penalties in the RL training pipeline
>> clean dashboard >> clean dashboard
@ -68,4 +73,7 @@ use existing checkpoint manager if it;s not too bloated as well. otherwise re-im
- [ ] Chart updates every second - [ ] Chart updates every second
- [ ] No flickering or data loss - [ ] No flickering or data loss
- [ ] WebSocket connection stable - [ ] WebSocket connection stable
- [ ] Memory usage reasonable - [ ] Memory usage reasonable

View File

@ -93,7 +93,6 @@ class TradeSignal:
# MassiveRLNetwork is now imported from NN.models.cob_rl_model # MassiveRLNetwork is now imported from NN.models.cob_rl_model
class RealtimeRLCOBTrader: class RealtimeRLCOBTrader:
""" """
Real-time RL trader using COB data with comprehensive subscriber system Real-time RL trader using COB data with comprehensive subscriber system

View File

@ -332,7 +332,6 @@ class SharedCOBService:
return base_stats return base_stats
# Global service instance access functions # Global service instance access functions
def get_shared_cob_service(symbols: List[str] = None, data_provider: DataProvider = None) -> SharedCOBService: def get_shared_cob_service(symbols: List[str] = None, data_provider: DataProvider = None) -> SharedCOBService:

View File

@ -36,7 +36,6 @@ from typing import Dict, List, Optional, Tuple, Any
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum from enum import Enum
# Setup logger immediately after logging import # Setup logger immediately after logging import
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -167,7 +166,6 @@ except ImportError:
TrainingDataPacket = None TrainingDataPacket = None
print("Warning: TrainingDataPacket could not be imported. Using fallback interface.") print("Warning: TrainingDataPacket could not be imported. Using fallback interface.")
class TrendDirection(Enum): class TrendDirection(Enum):
UP = "up" UP = "up"
DOWN = "down" DOWN = "down"
@ -964,7 +962,6 @@ class WilliamsMarketStructure:
else: else:
y_train_batch = y_train y_train_batch = y_train
logger.info(f"CNN Training with X_shape: {X_train_batch.shape}, y_shape: {y_train_batch.shape}") logger.info(f"CNN Training with X_shape: {X_train_batch.shape}, y_shape: {y_train_batch.shape}")
# Perform a single step of training (online learning) # Perform a single step of training (online learning)
# Use the wrapper's fit method, not the model's directly # Use the wrapper's fit method, not the model's directly
@ -1340,7 +1337,6 @@ class WilliamsMarketStructure:
# Emergency fallback: return features as-is but scaled to [0,1] roughly # Emergency fallback: return features as-is but scaled to [0,1] roughly
return np.clip(features / (np.max(np.abs(features)) + 1e-8), -1.0, 1.0) return np.clip(features / (np.max(np.abs(features)) + 1e-8), -1.0, 1.0)
def _get_cnn_ground_truth(self, def _get_cnn_ground_truth(self,
previous_pivot_info: Dict[str, Any], # Contains 'pivot': SwingPoint obj of N-1 previous_pivot_info: Dict[str, Any], # Contains 'pivot': SwingPoint obj of N-1
actual_current_pivot: SwingPoint # This is pivot N actual_current_pivot: SwingPoint # This is pivot N

View File

@ -194,7 +194,6 @@ class ImprovedRewardCalculator:
return reward return reward
# Example usage: # Example usage:
if __name__ == "__main__": if __name__ == "__main__":
# Create calculator instance # Create calculator instance

View File

@ -31,7 +31,7 @@ logger = logging.getLogger(__name__)
# Import core components # Import core components
from core.config import get_config from core.config import get_config
from core.data_provider import DataProvider from core.data_provider import DataProvider
from core.orchestrator import TradingOrchestrator from core.enhanced_orchestrator import EnhancedTradingOrchestrator
from core.trading_executor import TradingExecutor from core.trading_executor import TradingExecutor
# Import layout and component managers # Import layout and component managers
@ -60,13 +60,22 @@ from core.realtime_rl_cob_trader import RealtimeRLCOBTrader, PredictionResult
class CleanTradingDashboard: class CleanTradingDashboard:
"""Clean, modular trading dashboard implementation""" """Clean, modular trading dashboard implementation"""
def __init__(self, data_provider: DataProvider = None, orchestrator: TradingOrchestrator = None, trading_executor: TradingExecutor = None): def __init__(self, data_provider: DataProvider = None, orchestrator: EnhancedTradingOrchestrator = None, trading_executor: TradingExecutor = None):
self.config = get_config() self.config = get_config()
# Initialize components # Initialize components
self.data_provider = data_provider or DataProvider() self.data_provider = data_provider or DataProvider()
self.orchestrator = orchestrator self.trading_executor = trading_executor or TradingExecutor()
self.trading_executor = trading_executor
# Initialize orchestrator with enhanced capabilities
if orchestrator is None:
self.orchestrator = EnhancedTradingOrchestrator(
data_provider=self.data_provider,
symbols=['ETH/USDT', 'BTC/USDT'],
enhanced_rl_training=True
)
else:
self.orchestrator = orchestrator
# Initialize layout and component managers # Initialize layout and component managers
self.layout_manager = DashboardLayoutManager( self.layout_manager = DashboardLayoutManager(
@ -126,6 +135,42 @@ class CleanTradingDashboard:
logger.info("Clean Trading Dashboard initialized with COB RL integration") logger.info("Clean Trading Dashboard initialized with COB RL integration")
def load_model_dynamically(self, model_name: str, model_type: str, model_path: str = None) -> bool:
"""Dynamically load a model at runtime"""
try:
if hasattr(self.orchestrator, 'load_model'):
success = self.orchestrator.load_model(model_name, model_type, model_path)
if success:
logger.info(f"Successfully loaded model: {model_name}")
return True
return False
except Exception as e:
logger.error(f"Error loading model {model_name}: {e}")
return False
def unload_model_dynamically(self, model_name: str) -> bool:
"""Dynamically unload a model at runtime"""
try:
if hasattr(self.orchestrator, 'unload_model'):
success = self.orchestrator.unload_model(model_name)
if success:
logger.info(f"Successfully unloaded model: {model_name}")
return True
return False
except Exception as e:
logger.error(f"Error unloading model {model_name}: {e}")
return False
def get_loaded_models_status(self) -> Dict[str, Any]:
"""Get status of all loaded models"""
try:
if hasattr(self.orchestrator, 'list_loaded_models'):
return self.orchestrator.list_loaded_models()
return {'loaded_models': {}, 'total_models': 0, 'system_status': 'NO_ORCHESTRATOR'}
except Exception as e:
logger.error(f"Error getting model status: {e}")
return {'loaded_models': {}, 'total_models': 0, 'system_status': 'ERROR'}
def _get_initial_balance(self) -> float: def _get_initial_balance(self) -> float:
"""Get initial balance from trading executor or default""" """Get initial balance from trading executor or default"""
try: try:

View File

@ -537,7 +537,6 @@ class COBDashboardServer:
logger.error(f"Error in cleanup: {e}") logger.error(f"Error in cleanup: {e}")
await asyncio.sleep(300) await asyncio.sleep(300)
async def main(): async def main():
"""Main entry point""" """Main entry point"""
# Set up logging # Set up logging
@ -565,6 +564,5 @@ async def main():
if 'server' in locals(): if 'server' in locals():
await server.stop() await server.stop()
if __name__ == "__main__": if __name__ == "__main__":
asyncio.run(main()) asyncio.run(main())