import json
from datetime import datetime, timezone

results = [
    {
        "candidate_id": "candidate_2026-07-10T13-15-00Z_short_liquidity_sweep_reversal",
        "timestamp": "2026-07-10T13:15:00Z",
        "decision": "rejected",
        "reason": "At 13:15, short candidate appears after a sharp drop from H4 high (4117 to 4085). We are in discount after a huge drop. Shorting at 13:15 into local support near 4085 is low probability.",
        "htf_context": "H4 had huge push up to 4117 then retraced. H1 dropped from 4117 high back down to 4094. Overall still somewhat bullish on HTF but locally bearish.",
        "m30_structure": "M30 just had a sharp liquidity sweep to the downside (4085). Shorting here is late.",
        "m15_m5_execution": "M15 candle at 13:15 sweeps down to 4085 and closes at 4087.6. Going short here is selling at the bottom of a sweep.",
        "entry": None,
        "stop": None,
        "target": None,
        "r": None,
        "promoted_to_journal": False
    },
    {
        "candidate_id": "candidate_2026-07-10T14-15-00Z_long_liquidity_sweep_reversal",
        "timestamp": "2026-07-10T14:15:00Z",
        "decision": "rejected",
        "reason": "At 14:15, price pushes to 4109 then dumps to 4072 on the next 15m candle (14:30). Long setup would have been instantly stopped out.",
        "htf_context": "Price failed to hold higher support and broke down aggressively.",
        "m30_structure": "Heavy bearish momentum taking out previous lows.",
        "m15_m5_execution": "M15 at 14:15 looks like a weak push up (close 4105.4) before massive dump to 4072 at 14:30.",
        "entry": None,
        "stop": None,
        "target": None,
        "r": None,
        "promoted_to_journal": False
    },
    {
        "candidate_id": "candidate_2026-07-10T15-00-00Z_long_liquidity_sweep_reversal",
        "timestamp": "2026-07-10T15:00:00Z",
        "decision": "accepted",
        "reason": "Massive liquidity sweep down to 4072 at 14:30, immediate aggressive recovery. 15:00 candle confirms support holding above 4091. Perfect reversal setup post-sweep.",
        "htf_context": "Deep sweep of previous H4/H1 consolidation zones, aggressive rejection wicks.",
        "m30_structure": "Liquidity taken below 4085, V-shape recovery.",
        "m15_m5_execution": "At 14:30, huge wick down to 4072, close at 4099. 14:45 retests 4091. 15:00 opens 4092, pushes to 4101. Long entry around 4098, SL below 14:45 wick 4091, TP at recent highs 4114.",
        "entry": 4098.0,
        "stop": 4091.0,
        "target": 4114.0,
        "r": 2.28,
        "promoted_to_journal": True
    }
]

with open('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_results/replay_result_00786_00789.json', 'w') as f:
    json.dump(results, f, indent=2)

with open('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_progress.json', 'r') as f:
    prog = json.load(f)

prog['cursor']['next_index'] = 789
prog['cursor']['processed_count'] = 789
prog['cursor']['accepted_count'] += 1
prog['cursor']['rejected_count'] += 2
prog['cursor']['last_candidate_id'] = "candidate_2026-07-10T15-00-00Z_long_liquidity_sweep_reversal"
prog['cursor']['last_updated'] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

if "hybrid/reviews/manual_replay_results/replay_result_00786_00789.json" not in prog['runs'][0]['result_files']:
    prog['runs'][0]['result_files'].append("hybrid/reviews/manual_replay_results/replay_result_00786_00789.json")
    prog['runs'][0]['decision_counts']['rejected'] += 2
    prog['runs'][0]['decision_counts']['accepted'] += 1

with open('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_progress.json', 'w') as f:
    json.dump(prog, f, indent=2)

print("Progress updated.")
