better pivots

This commit is contained in:
Dobromir Popov
2025-05-31 00:33:07 +03:00
parent 7a0e468c3e
commit 3a748daff2
3 changed files with 175 additions and 108 deletions

View File

@ -3010,10 +3010,9 @@ class TradingDashboard:
# Update internal model storage
for model_type, model_data in loaded_models.items():
model_info = model_data['info']
logger.info(f"Using best {model_type} model: {model_info.model_name} "
f"(Score: {model_info.metrics.get_composite_score():.3f})")
logger.info(f"Using best {model_type} model: {model_info.model_name} (Score: {model_info.metrics.get_composite_score():.3f})")
else:
else:
logger.info("No managed models available, falling back to legacy loading")
# Fallback to original model loading logic
self._load_legacy_models()
@ -3021,7 +3020,7 @@ class TradingDashboard:
except ImportError:
logger.warning("ModelManager not available, using legacy model loading")
self._load_legacy_models()
except Exception as e:
except Exception as e:
logger.error(f"Error loading models via ModelManager: {e}")
self._load_legacy_models()
@ -3053,7 +3052,7 @@ class TradingDashboard:
with torch.no_grad():
if hasattr(feature_matrix, 'shape') and len(feature_matrix.shape) == 2:
feature_tensor = torch.FloatTensor(feature_matrix).unsqueeze(0)
else:
else:
feature_tensor = torch.FloatTensor(feature_matrix)
prediction = self.model(feature_tensor)
@ -3090,7 +3089,7 @@ class TradingDashboard:
})
logger.info(f"Loaded CNN model: {model_file}")
except Exception as e:
except Exception as e:
logger.warning(f"Failed to load CNN model {model_file}: {e}")
# Check for RL models
@ -3101,12 +3100,12 @@ class TradingDashboard:
try:
checkpoint_path = os.path.join(rl_models_dir, model_file)
class RLWrapper:
def __init__(self, checkpoint_path):
class RLWrapper:
def __init__(self, checkpoint_path):
self.checkpoint_path = checkpoint_path
self.checkpoint = torch.load(checkpoint_path, map_location='cpu')
def predict(self, feature_matrix):
def predict(self, feature_matrix):
# Mock RL prediction
if hasattr(feature_matrix, 'shape'):
state_sum = np.sum(feature_matrix) % 100
@ -3117,7 +3116,7 @@ class TradingDashboard:
action_probs = [0.1, 0.1, 0.8] # BUY
elif state_sum < 30:
action_probs = [0.8, 0.1, 0.1] # SELL
else:
else:
action_probs = [0.2, 0.6, 0.2] # HOLD
return np.array(action_probs)
@ -3137,7 +3136,7 @@ class TradingDashboard:
})
logger.info(f"Loaded RL model: {model_file}")
except Exception as e:
except Exception as e:
logger.warning(f"Failed to load RL model {model_file}: {e}")
total_models = sum(len(models) for models in self.available_models.values())