work with order execution - we are forced to do limit orders over the API

This commit is contained in:
Dobromir Popov
2025-07-14 13:36:07 +03:00
parent d7205a9745
commit f861559319
4 changed files with 387 additions and 182 deletions

View File

@ -373,6 +373,12 @@ class EnhancedCNN(nn.Module):
def _check_rebuild_network(self, features):
"""Check if network needs to be rebuilt for different feature dimensions"""
# Prevent rebuilding with zero or invalid dimensions
if features <= 0:
logger.error(f"Invalid feature dimension: {features}. Cannot rebuild network with zero or negative dimensions.")
logger.error(f"Current feature_dim: {self.feature_dim}. Keeping existing network.")
return False
if features != self.feature_dim:
logger.info(f"Rebuilding network for new feature dimension: {features} (was {self.feature_dim})")
self.feature_dim = features
@ -386,6 +392,20 @@ class EnhancedCNN(nn.Module):
"""Forward pass through the ULTRA MASSIVE network"""
batch_size = x.size(0)
# Validate input dimensions to prevent zero-element tensor issues
if x.numel() == 0:
logger.error(f"Forward pass received empty tensor with shape {x.shape}")
# Return default output to prevent crash
default_output = torch.zeros(batch_size, self.n_actions, device=x.device)
return default_output
# Check for zero feature dimensions
if len(x.shape) > 1 and any(dim == 0 for dim in x.shape[1:]):
logger.error(f"Forward pass received tensor with zero feature dimensions: {x.shape}")
# Return default output to prevent crash
default_output = torch.zeros(batch_size, self.n_actions, device=x.device)
return default_output
# Process different input shapes
if len(x.shape) > 2:
# Handle 4D input [batch, timeframes, window, features] or 3D input [batch, timeframes, features]