stability
This commit is contained in:
@ -1493,6 +1493,17 @@ class TradingOrchestrator:
|
||||
if not base_data:
|
||||
logger.warning(f"Cannot build BaseDataInput for predictions: {symbol}")
|
||||
return predictions
|
||||
|
||||
# Validate base_data has proper feature vector
|
||||
if hasattr(base_data, 'get_feature_vector'):
|
||||
try:
|
||||
feature_vector = base_data.get_feature_vector()
|
||||
if feature_vector is None or (isinstance(feature_vector, np.ndarray) and feature_vector.size == 0):
|
||||
logger.warning(f"BaseDataInput has empty feature vector for {symbol}")
|
||||
return predictions
|
||||
except Exception as e:
|
||||
logger.warning(f"Error getting feature vector from BaseDataInput for {symbol}: {e}")
|
||||
return predictions
|
||||
|
||||
# log all registered models
|
||||
logger.debug(f"inferencing registered models: {self.model_registry.models}")
|
||||
@ -1691,6 +1702,15 @@ class TradingOrchestrator:
|
||||
try:
|
||||
logger.debug(f"Storing inference for {model_name}: {prediction.action} (confidence: {prediction.confidence:.3f})")
|
||||
|
||||
# Validate model_input before storing
|
||||
if model_input is None:
|
||||
logger.warning(f"Skipping inference storage for {model_name}: model_input is None")
|
||||
return
|
||||
|
||||
if isinstance(model_input, dict) and not model_input:
|
||||
logger.warning(f"Skipping inference storage for {model_name}: model_input is empty dict")
|
||||
return
|
||||
|
||||
# Extract symbol from prediction if not provided
|
||||
if symbol is None:
|
||||
symbol = getattr(prediction, 'symbol', 'ETH/USDT') # Default to ETH/USDT if not available
|
||||
@ -2569,6 +2589,25 @@ class TradingOrchestrator:
|
||||
|
||||
# Method 3: Dictionary with feature data
|
||||
if isinstance(model_input, dict):
|
||||
# Check if dictionary is empty
|
||||
if not model_input:
|
||||
logger.warning(f"Empty dictionary passed as model_input for {model_name}, using fallback")
|
||||
# Try to use data provider to build state as fallback
|
||||
if hasattr(self, 'data_provider'):
|
||||
try:
|
||||
base_data = self.data_provider.build_base_data_input('ETH/USDT')
|
||||
if base_data and hasattr(base_data, 'get_feature_vector'):
|
||||
state = base_data.get_feature_vector()
|
||||
if isinstance(state, np.ndarray):
|
||||
logger.debug(f"Used data provider fallback for empty dict in {model_name}")
|
||||
return state
|
||||
except Exception as e:
|
||||
logger.debug(f"Data provider fallback failed for empty dict in {model_name}: {e}")
|
||||
|
||||
# Final fallback: return default state
|
||||
logger.warning(f"Using default state for empty dict in {model_name}")
|
||||
return np.zeros(403, dtype=np.float32) # Default state size
|
||||
|
||||
# Try to extract features from dictionary
|
||||
if 'features' in model_input:
|
||||
features = model_input['features']
|
||||
@ -2589,6 +2628,8 @@ class TradingOrchestrator:
|
||||
|
||||
if feature_list:
|
||||
return np.array(feature_list, dtype=np.float32)
|
||||
else:
|
||||
logger.warning(f"No numerical features found in dictionary for {model_name}, using fallback")
|
||||
|
||||
# Method 4: List or tuple
|
||||
if isinstance(model_input, (list, tuple)):
|
||||
|
Reference in New Issue
Block a user