diff --git a/NN/models/advanced_transformer_trading.py b/NN/models/advanced_transformer_trading.py index 2fc7b59..932f96a 100644 --- a/NN/models/advanced_transformer_trading.py +++ b/NN/models/advanced_transformer_trading.py @@ -452,6 +452,14 @@ class AdvancedTradingTransformer(nn.Module): """ batch_size, seq_len = price_data.shape[:2] + # Handle different input dimensions - expand to sequence if needed + if cob_data.dim() == 2: # (batch, features) -> (batch, seq_len, features) + cob_data = cob_data.unsqueeze(1).expand(batch_size, seq_len, -1) + if tech_data.dim() == 2: # (batch, features) -> (batch, seq_len, features) + tech_data = tech_data.unsqueeze(1).expand(batch_size, seq_len, -1) + if market_data.dim() == 2: # (batch, features) -> (batch, seq_len, features) + market_data = market_data.unsqueeze(1).expand(batch_size, seq_len, -1) + # Project inputs to model dimension price_emb = self.price_projection(price_data) cob_emb = self.cob_projection(cob_data) diff --git a/NN/models/saved/checkpoint_metadata.json b/NN/models/saved/checkpoint_metadata.json index 427d241..51ec246 100644 --- a/NN/models/saved/checkpoint_metadata.json +++ b/NN/models/saved/checkpoint_metadata.json @@ -271,15 +271,15 @@ ], "decision": [ { - "checkpoint_id": "decision_20250702_012558", + "checkpoint_id": "decision_20250702_013257", "model_name": "decision", "model_type": "decision_fusion", - "file_path": "NN\\models\\saved\\decision\\decision_20250702_012558.pt", - "created_at": "2025-07-02T01:25:58.614455", + "file_path": "NN\\models\\saved\\decision\\decision_20250702_013257.pt", + "created_at": "2025-07-02T01:32:57.057698", "file_size_mb": 0.06720924377441406, - "performance_score": 9.999991886192655, + "performance_score": 9.99999352005137, "accuracy": null, - "loss": 8.113807345618998e-06, + "loss": 6.479948628599987e-06, "val_accuracy": null, "val_loss": null, "reward": null, @@ -291,15 +291,15 @@ "wandb_artifact_name": null }, { - "checkpoint_id": "decision_20250702_012504", + "checkpoint_id": "decision_20250702_013256", "model_name": "decision", "model_type": "decision_fusion", - "file_path": "NN\\models\\saved\\decision\\decision_20250702_012504.pt", - "created_at": "2025-07-02T01:25:04.285477", + "file_path": "NN\\models\\saved\\decision\\decision_20250702_013256.pt", + "created_at": "2025-07-02T01:32:56.667169", "file_size_mb": 0.06720924377441406, - "performance_score": 9.999991852067678, + "performance_score": 9.999993471487318, "accuracy": null, - "loss": 8.147932321987486e-06, + "loss": 6.528512681061979e-06, "val_accuracy": null, "val_loss": null, "reward": null, @@ -311,15 +311,15 @@ "wandb_artifact_name": null }, { - "checkpoint_id": "decision_20250702_012502", + "checkpoint_id": "decision_20250702_013255", "model_name": "decision", "model_type": "decision_fusion", - "file_path": "NN\\models\\saved\\decision\\decision_20250702_012502.pt", - "created_at": "2025-07-02T01:25:02.958656", + "file_path": "NN\\models\\saved\\decision\\decision_20250702_013255.pt", + "created_at": "2025-07-02T01:32:55.915359", "file_size_mb": 0.06720924377441406, - "performance_score": 9.999991847589234, + "performance_score": 9.999993469737547, "accuracy": null, - "loss": 8.152410765381393e-06, + "loss": 6.5302624539599814e-06, "val_accuracy": null, "val_loss": null, "reward": null, @@ -331,15 +331,15 @@ "wandb_artifact_name": null }, { - "checkpoint_id": "decision_20250702_012503", + "checkpoint_id": "decision_20250702_013255", "model_name": "decision", "model_type": "decision_fusion", - "file_path": "NN\\models\\saved\\decision\\decision_20250702_012503.pt", - "created_at": "2025-07-02T01:25:03.108239", + "file_path": "NN\\models\\saved\\decision\\decision_20250702_013255.pt", + "created_at": "2025-07-02T01:32:55.774316", "file_size_mb": 0.06720924377441406, - "performance_score": 9.99999184242316, + "performance_score": 9.99999346914947, "accuracy": null, - "loss": 8.157576839933662e-06, + "loss": 6.530850530594989e-06, "val_accuracy": null, "val_loss": null, "reward": null, @@ -351,15 +351,15 @@ "wandb_artifact_name": null }, { - "checkpoint_id": "decision_20250702_012502", + "checkpoint_id": "decision_20250702_013255", "model_name": "decision", "model_type": "decision_fusion", - "file_path": "NN\\models\\saved\\decision\\decision_20250702_012502.pt", - "created_at": "2025-07-02T01:25:02.603966", + "file_path": "NN\\models\\saved\\decision\\decision_20250702_013255.pt", + "created_at": "2025-07-02T01:32:55.646001", "file_size_mb": 0.06720924377441406, - "performance_score": 9.999991812171043, + "performance_score": 9.99999346889822, "accuracy": null, - "loss": 8.187828957696905e-06, + "loss": 6.531101780155828e-06, "val_accuracy": null, "val_loss": null, "reward": null, diff --git a/web/clean_dashboard.py b/web/clean_dashboard.py index 87a1bfd..f46cbe4 100644 --- a/web/clean_dashboard.py +++ b/web/clean_dashboard.py @@ -239,10 +239,10 @@ class CleanTradingDashboard: from NN.models.advanced_transformer_trading import create_trading_transformer, TradingTransformerConfig config = TradingTransformerConfig( - d_model=1024, # 2x increase for 46M parameters - n_heads=16, # 2x increase - n_layers=12, # 2x increase - seq_len=150, # 1.5x increase + d_model=512, # Optimized for 46M parameters + n_heads=8, # Optimized + n_layers=8, # Optimized + seq_len=100, # Optimized n_actions=3, use_multi_scale_attention=True, use_market_regime_detection=True, @@ -4603,10 +4603,10 @@ class CleanTradingDashboard: # Create transformer if not exists if transformer_model is None or transformer_trainer is None: config = TradingTransformerConfig( - d_model=1024, # 2x increase for 46M parameters - n_heads=16, # 2x increase - n_layers=12, # 2x increase - seq_len=150, # 1.5x increase + d_model=512, # Optimized for 46M parameters + n_heads=8, # Optimized + n_layers=8, # Optimized + seq_len=100, # Optimized n_actions=3, use_multi_scale_attention=True, use_market_regime_detection=True, diff --git a/web/layout_manager.py b/web/layout_manager.py index c0e3e33..7125e03 100644 --- a/web/layout_manager.py +++ b/web/layout_manager.py @@ -200,98 +200,64 @@ class DashboardLayoutManager: ]) def _create_cob_and_trades_row(self): - """Creates the row for COB ladders, closed trades, and model status.""" - return html.Div( - [ + """Creates the row for COB ladders, closed trades, and model status - REORGANIZED LAYOUT""" + return html.Div([ + # Top row: COB Ladders (left) and Models/Training (right) + html.Div([ # Left side: COB Ladders (60% width) - html.Div( - [ + html.Div([ + html.Div([ + # ETH/USDT COB + html.Div([ + html.Div( + id="eth-cob-content", + className="card-body p-2", + ) + ], className="card", style={"flex": "1"}), + + # BTC/USDT COB + html.Div([ + html.Div( + id="btc-cob-content", + className="card-body p-2", + ) + ], className="card", style={"flex": "1", "marginLeft": "1rem"}), + ], className="d-flex") + ], style={"width": "60%"}), + + # Right side: Models & Training Progress (40% width) - MOVED UP + html.Div([ + html.Div([ + html.Div([ + html.H6([ + html.I(className="fas fa-brain me-2"), + "Models & Training Progress", + ], className="card-title mb-2"), + html.Div( + id="training-metrics", + style={"height": "300px", "overflowY": "auto"}, # Increased height + ), + ], className="card-body p-2") + ], className="card") + ], style={"width": "38%", "marginLeft": "2%"}), + ], className="d-flex mb-3"), + + # Bottom row: Closed Trades (full width) - MOVED BELOW COB + html.Div([ + html.Div([ + html.Div([ + html.H6([ + html.I(className="fas fa-history me-2"), + "Recent Closed Trades", + ], className="card-title mb-2"), html.Div( - [ - # ETH/USDT COB - html.Div( - [ - html.Div( - id="eth-cob-content", - className="card-body p-2", - ) - ], - className="card", - style={"flex": "1"}, - ), - # BTC/USDT COB - html.Div( - [ - html.Div( - id="btc-cob-content", - className="card-body p-2", - ) - ], - className="card", - style={"flex": "1", "marginLeft": "1rem"}, - ), - ], - className="d-flex", - ) - ], - style={"width": "60%"}, - ), - # Right side: Trades and Model Status (40% width) - html.Div( - [ - # Closed Trades - html.Div( - [ - html.Div( - [ - html.H6( - [ - html.I(className="fas fa-history me-2"), - "Closed Trades", - ], - className="card-title mb-2", - ), - html.Div( - id="closed-trades-table", - style={"height": "250px", "overflowY": "auto"}, - ), - ], - className="card-body p-2", - ) - ], - className="card mb-3", + id="closed-trades-table", + style={"height": "200px", "overflowY": "auto"}, # Reduced height ), - # Model Status - html.Div( - [ - html.Div( - [ - html.H6( - [ - html.I(className="fas fa-brain me-2"), - "Models & Training Progress", - ], - className="card-title mb-2", - ), - html.Div( - id="training-metrics", - style={ - "height": "250px", - "overflowY": "auto", - }, - ), - ], - className="card-body p-2", - ) - ], - className="card", - ), - ], - style={"width": "38%", "marginLeft": "2%"}, - ), - ], - className="d-flex mb-3", - ) + ], className="card-body p-2") + ], className="card") + ]) + ]) def _create_analytics_and_performance_row(self): """Create the combined analytics and performance row with COB data, trades, and training progress"""