fix broken merge

This commit is contained in:
Dobromir Popov
2025-10-08 20:02:41 +03:00
parent a468c75c47
commit 270ba2e52b
12 changed files with 493 additions and 86 deletions

View File

@@ -1946,8 +1946,6 @@ class CleanTradingDashboard:
logger.error(f"Error updating trades table: {e}")
return html.P(f"Error: {str(e)}", className="text-danger")
@self.app.callback(
@self.app.callback(
[Output('eth-cob-content', 'children'),
Output('btc-cob-content', 'children')],
@@ -6353,10 +6351,10 @@ class CleanTradingDashboard:
# Additional training weight for executed signals
if signal['executed']:
# Log signal processing
status = "EXECUTED" if signal['executed'] else ("BLOCKED" if signal['blocked'] else "PENDING")
logger.info(f"[{status}] {signal['action']} signal for {signal['symbol']} "
f"(conf: {signal['confidence']:.2f}, model: {signal.get('model', 'UNKNOWN')})")
# Log signal processing
status = "EXECUTED" if signal['executed'] else ("BLOCKED" if signal['blocked'] else "PENDING")
logger.info(f"[{status}] {signal['action']} signal for {signal['symbol']} "
f"(conf: {signal['confidence']:.2f}, model: {signal.get('model', 'UNKNOWN')})")
except Exception as e:
logger.error(f"Error processing dashboard signal: {e}")
@@ -6512,7 +6510,7 @@ class CleanTradingDashboard:
if hasattr(self.orchestrator.rl_agent, 'replay'):
loss = self.orchestrator.rl_agent.replay()
if loss is not None:
logger.debug(f"DQN training loss: {loss:.4f}")
except Exception as e:
logger.debug(f"Error training DQN on prediction: {e}")
@@ -8049,8 +8047,14 @@ class CleanTradingDashboard:
logger.warning("No checkpoint manager available for model storage")
return False
except Exception as e:
logger.warning(f"❌ Failed to store Decision Fusion model: {e}")
# Store models and handle any exceptions
try:
# Store Decision Fusion model
if hasattr(self.orchestrator, 'decision_fusion_network') and self.orchestrator.decision_fusion_network:
logger.info("💾 Storing Decision Fusion model...")
# Add storage logic here
except Exception as e:
logger.warning(f"❌ Failed to store Decision Fusion model: {e}")
# 5. Verification Step - Try to load checkpoints to verify they work
logger.info("🔍 Verifying stored checkpoints...")
@@ -9182,6 +9186,9 @@ class CleanTradingDashboard:
logger.debug(f"COB data retrieved from data provider for {symbol}: {len(bids)} bids, {len(asks)} asks")
except Exception as e:
logger.error(f"Error retrieving COB data for {symbol}: {e}")
return None
def _generate_bucketed_cob_data(self, symbol: str, cob_snapshot: dict):
"""Generate bucketed COB data for model feeding"""
try:
@@ -9775,6 +9782,53 @@ class CleanTradingDashboard:
'total_pnl': 0.0
}
def run_chained_inference(self, symbol: str, n_steps: int = 10):
"""Run chained inference to trigger initial predictions"""
try:
logger.info(f"🔗 Running chained inference for {symbol} with {n_steps} steps")
if self.orchestrator is None:
logger.warning("❌ No orchestrator available for chained inference")
return
# Trigger initial predictions by calling make_trading_decision
import asyncio
async def _run_inference():
try:
# Run multiple inference steps
for step in range(n_steps):
logger.debug(f"🔗 Running inference step {step + 1}/{n_steps}")
decision = await self.orchestrator.make_trading_decision(symbol)
if decision:
logger.debug(f"🔗 Step {step + 1}: Decision made for {symbol}")
else:
logger.debug(f"🔗 Step {step + 1}: No decision available for {symbol}")
# Small delay between steps
await asyncio.sleep(0.1)
logger.info(f"🔗 Chained inference completed for {symbol}")
except Exception as e:
logger.error(f"❌ Error in chained inference: {e}")
# Run the async inference
try:
loop = asyncio.get_event_loop()
if loop.is_running():
# If loop is already running, create a task
asyncio.create_task(_run_inference())
else:
# If no loop is running, run it directly
asyncio.run(_run_inference())
except RuntimeError:
# Fallback: try to run in a new event loop
asyncio.run(_run_inference())
except Exception as e:
logger.error(f"❌ Chained inference failed: {e}")
def run_server(self, host='127.0.0.1', port=8050, debug=False):
"""Start the Dash server"""
try:
@@ -9862,6 +9916,8 @@ class CleanTradingDashboard:
"""Connect to orchestrator for real trading signals"""
try:
if self.orchestrator and hasattr(self.orchestrator, 'add_decision_callback'):
self.orchestrator.add_decision_callback(self._on_trading_decision)
logger.info("✅ Orchestrator decision callback registered")
else:
logger.warning("Orchestrator not available or doesn't support callbacks")
except Exception as e:
@@ -11179,3 +11235,4 @@ def create_clean_dashboard(data_provider: Optional[DataProvider] = None, orchest
data_provider=data_provider,
orchestrator=orchestrator,
trading_executor=trading_executor
)