import json

with open('/home/jerome/Perso/freqtradeDocker/user_data/hyperopts/hyperopt_results_2025-05-21_XX.json') as f:
    results = json.load(f)

def custom_score(res):
    stake = res.get('avg_stake_amount', 1e6)
    duration = res.get('avg_duration', 1e6)
    profit = res.get('profit_total_usdt', -1e6)
    return -stake * 0.4 - duration * 0.3 + profit * 0.3

best = sorted(results, key=custom_score, reverse=True)[0]
print("Best configuration based on custom score:", best)
