merge and kill task fixes
This commit is contained in:
@@ -279,9 +279,12 @@ class CleanTradingDashboard:
|
||||
logger.warning(f"Error loading config settings, using defaults: {e}")
|
||||
# Keep default values
|
||||
|
||||
# Initialize starting balance for metrics tracking
|
||||
self.starting_balance = self._get_initial_balance()
|
||||
|
||||
# Initialize layout and component managers
|
||||
self.layout_manager = DashboardLayoutManager(
|
||||
starting_balance=self._get_initial_balance(),
|
||||
starting_balance=self.starting_balance,
|
||||
trading_executor=self.trading_executor,
|
||||
dashboard=self
|
||||
)
|
||||
@@ -323,7 +326,6 @@ class CleanTradingDashboard:
|
||||
self._sync_ui_state_from_orchestrator()
|
||||
|
||||
# Trading mode and cold start settings from config
|
||||
from core.config import get_config
|
||||
config = get_config()
|
||||
|
||||
# Initialize trading mode from config (default to simulation)
|
||||
@@ -2916,6 +2918,80 @@ class CleanTradingDashboard:
|
||||
# Return None if absolutely nothing available
|
||||
return None
|
||||
|
||||
def _check_exchange_connection(self) -> bool:
|
||||
"""Check if exchange connection is available"""
|
||||
try:
|
||||
# Check if data provider is connected
|
||||
if hasattr(self.data_provider, 'is_connected'):
|
||||
return self.data_provider.is_connected()
|
||||
|
||||
# Check if trading executor has active exchange connection
|
||||
if hasattr(self.trading_executor, 'is_connected'):
|
||||
return self.trading_executor.is_connected()
|
||||
|
||||
# Check if we can get current price (indicates connection)
|
||||
if hasattr(self.data_provider, 'get_current_price'):
|
||||
try:
|
||||
price = self.data_provider.get_current_price('ETH/USDT')
|
||||
return price is not None and price > 0
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
# Default to True if we can't determine (avoid false negatives)
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logger.debug(f"Error checking exchange connection: {e}")
|
||||
return False
|
||||
|
||||
def _train_all_models_on_prediction(self, signal: Dict):
|
||||
"""Train all models on prediction result"""
|
||||
try:
|
||||
# Get prediction outcome for training
|
||||
prediction_outcome = self._get_prediction_outcome_for_training(signal)
|
||||
if not prediction_outcome:
|
||||
return
|
||||
|
||||
# Delegate to orchestrator's training system if available
|
||||
if hasattr(self.orchestrator, 'train_on_signal'):
|
||||
try:
|
||||
self.orchestrator.train_on_signal(signal, prediction_outcome)
|
||||
return
|
||||
except Exception as e:
|
||||
logger.debug(f"Orchestrator training failed: {e}")
|
||||
|
||||
# Fallback: Train individual models
|
||||
try:
|
||||
# Train DQN on prediction
|
||||
if hasattr(self, '_train_dqn_on_prediction'):
|
||||
self._train_dqn_on_prediction(signal, prediction_outcome)
|
||||
except Exception as e:
|
||||
logger.debug(f"DQN training failed: {e}")
|
||||
|
||||
try:
|
||||
# Train CNN on prediction
|
||||
if hasattr(self, '_train_cnn_on_prediction'):
|
||||
self._train_cnn_on_prediction(signal, prediction_outcome)
|
||||
except Exception as e:
|
||||
logger.debug(f"CNN training failed: {e}")
|
||||
|
||||
try:
|
||||
# Train Transformer on prediction
|
||||
if hasattr(self, '_train_transformer_on_prediction'):
|
||||
self._train_transformer_on_prediction(signal, prediction_outcome)
|
||||
except Exception as e:
|
||||
logger.debug(f"Transformer training failed: {e}")
|
||||
|
||||
try:
|
||||
# Train COB RL on prediction
|
||||
if hasattr(self, '_train_cob_rl_on_prediction'):
|
||||
self._train_cob_rl_on_prediction(signal, prediction_outcome)
|
||||
except Exception as e:
|
||||
logger.debug(f"COB RL training failed: {e}")
|
||||
|
||||
except Exception as e:
|
||||
logger.debug(f"Error training models on prediction: {e}")
|
||||
|
||||
def _create_price_chart(self, symbol: str, show_pivots: bool = True, return_legend: bool = False):
|
||||
"""Create 1-minute main chart with 1-second mini chart - Updated every second
|
||||
If return_legend is True, returns (figure, legend_children) and keeps legend out of chart to avoid scale issues.
|
||||
|
||||
Reference in New Issue
Block a user