use enhanced orchestrator
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
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
|
||||
@ -69,3 +74,6 @@ use existing checkpoint manager if it;s not too bloated as well. otherwise re-im
|
||||
- [ ] No flickering or data loss
|
||||
- [ ] WebSocket connection stable
|
||||
- [ ] Memory usage reasonable
|
||||
|
||||
|
||||
|
||||
|
@ -93,7 +93,6 @@ class TradeSignal:
|
||||
|
||||
# MassiveRLNetwork is now imported from NN.models.cob_rl_model
|
||||
|
||||
|
||||
class RealtimeRLCOBTrader:
|
||||
"""
|
||||
Real-time RL trader using COB data with comprehensive subscriber system
|
||||
|
@ -332,7 +332,6 @@ class SharedCOBService:
|
||||
|
||||
return base_stats
|
||||
|
||||
|
||||
# Global service instance access functions
|
||||
|
||||
def get_shared_cob_service(symbols: List[str] = None, data_provider: DataProvider = None) -> SharedCOBService:
|
||||
|
@ -36,7 +36,6 @@ from typing import Dict, List, Optional, Tuple, Any
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
|
||||
# Setup logger immediately after logging import
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -167,7 +166,6 @@ except ImportError:
|
||||
TrainingDataPacket = None
|
||||
print("Warning: TrainingDataPacket could not be imported. Using fallback interface.")
|
||||
|
||||
|
||||
class TrendDirection(Enum):
|
||||
UP = "up"
|
||||
DOWN = "down"
|
||||
@ -964,7 +962,6 @@ class WilliamsMarketStructure:
|
||||
else:
|
||||
y_train_batch = y_train
|
||||
|
||||
|
||||
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)
|
||||
# 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
|
||||
return np.clip(features / (np.max(np.abs(features)) + 1e-8), -1.0, 1.0)
|
||||
|
||||
|
||||
def _get_cnn_ground_truth(self,
|
||||
previous_pivot_info: Dict[str, Any], # Contains 'pivot': SwingPoint obj of N-1
|
||||
actual_current_pivot: SwingPoint # This is pivot N
|
||||
|
@ -194,7 +194,6 @@ class ImprovedRewardCalculator:
|
||||
|
||||
return reward
|
||||
|
||||
|
||||
# Example usage:
|
||||
if __name__ == "__main__":
|
||||
# Create calculator instance
|
||||
|
@ -31,7 +31,7 @@ logger = logging.getLogger(__name__)
|
||||
# Import core components
|
||||
from core.config import get_config
|
||||
from core.data_provider import DataProvider
|
||||
from core.orchestrator import TradingOrchestrator
|
||||
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
|
||||
from core.trading_executor import TradingExecutor
|
||||
|
||||
# Import layout and component managers
|
||||
@ -60,13 +60,22 @@ from core.realtime_rl_cob_trader import RealtimeRLCOBTrader, PredictionResult
|
||||
class CleanTradingDashboard:
|
||||
"""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()
|
||||
|
||||
# Initialize components
|
||||
self.data_provider = data_provider or DataProvider()
|
||||
self.orchestrator = orchestrator
|
||||
self.trading_executor = trading_executor
|
||||
self.trading_executor = trading_executor or TradingExecutor()
|
||||
|
||||
# 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
|
||||
self.layout_manager = DashboardLayoutManager(
|
||||
@ -126,6 +135,42 @@ class CleanTradingDashboard:
|
||||
|
||||
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:
|
||||
"""Get initial balance from trading executor or default"""
|
||||
try:
|
||||
|
@ -537,7 +537,6 @@ class COBDashboardServer:
|
||||
logger.error(f"Error in cleanup: {e}")
|
||||
await asyncio.sleep(300)
|
||||
|
||||
|
||||
async def main():
|
||||
"""Main entry point"""
|
||||
# Set up logging
|
||||
@ -565,6 +564,5 @@ async def main():
|
||||
if 'server' in locals():
|
||||
await server.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
Reference in New Issue
Block a user