wip
This commit is contained in:
@@ -2097,13 +2097,20 @@ class TradingOrchestrator:
|
||||
|
||||
# Choose best action - safe way to handle max with key function
|
||||
if action_scores:
|
||||
# Add small random component to break ties and prevent pure bias
|
||||
import random
|
||||
for action in action_scores:
|
||||
# Add tiny random noise (±0.001) to break exact ties
|
||||
action_scores[action] += random.uniform(-0.001, 0.001)
|
||||
# Break exact ties deterministically (NO RANDOM DATA)
|
||||
# Use action order as tie-breaker: BUY > SELL > HOLD
|
||||
action_order = {'BUY': 3, 'SELL': 2, 'HOLD': 1}
|
||||
|
||||
# Find max score
|
||||
max_score = max(action_scores.values())
|
||||
|
||||
# If multiple actions have same score, prefer BUY > SELL > HOLD
|
||||
tied_actions = [action for action, score in action_scores.items() if score == max_score]
|
||||
if len(tied_actions) > 1:
|
||||
best_action = max(tied_actions, key=lambda a: action_order.get(a, 0))
|
||||
else:
|
||||
best_action = tied_actions[0]
|
||||
|
||||
best_action = max(action_scores.keys(), key=lambda k: action_scores[k])
|
||||
best_confidence = action_scores[best_action]
|
||||
|
||||
# DEBUG: Log action scores to understand bias
|
||||
|
||||
Reference in New Issue
Block a user