execution and training fixes

This commit is contained in:
Dobromir Popov
2025-07-04 20:45:39 +03:00
parent 0c4c682498
commit ed42e7c238
10 changed files with 879 additions and 79 deletions

View File

@ -1240,12 +1240,26 @@ class TradingOrchestrator:
enhanced_features = feature_matrix
if enhanced_features is not None:
# Get CNN prediction
# Get CNN prediction - use the actual underlying model
try:
action_probs, confidence = model.predict_timeframe(enhanced_features, timeframe)
except AttributeError:
# Fallback to generic predict method
action_probs, confidence = model.predict(enhanced_features)
if hasattr(model.model, 'act'):
# Use the CNN's act method
action_result = model.model.act(enhanced_features, explore=False)
if isinstance(action_result, tuple):
action_idx, confidence = action_result
else:
action_idx = action_result
confidence = 0.7 # Default confidence
# Convert to action probabilities
action_probs = [0.1, 0.1, 0.8] # Default distribution
action_probs[action_idx] = confidence
else:
# Fallback to generic predict method
action_probs, confidence = model.predict(enhanced_features)
except Exception as e:
logger.warning(f"CNN prediction failed: {e}")
action_probs, confidence = None, None
if action_probs is not None:
# Convert to prediction object
@ -1290,8 +1304,15 @@ class TradingOrchestrator:
if state is None:
return None
# Get RL agent's action and confidence
action_idx, confidence = model.act_with_confidence(state)
# Get RL agent's action and confidence - use the actual underlying model
if hasattr(model.model, 'act_with_confidence'):
action_idx, confidence = model.model.act_with_confidence(state)
elif hasattr(model.model, 'act'):
action_idx = model.model.act(state, explore=False)
confidence = 0.7 # Default confidence for basic act method
else:
logger.error(f"RL model {model.name} has no act method")
return None
action_names = ['SELL', 'HOLD', 'BUY']
action = action_names[action_idx]