import json
import os
from datetime import datetime

results = []

results.append({
    "candidate_id": "candidate_2026-07-05T23-15-00Z_long_liquidity_sweep_reversal",
    "timestamp": "2026-07-05T23:15:00Z",
    "decision": "rejected",
    "reason": "M5 shows strong rejection and bearish expansion after 4202 sweep, not a long setup",
    "htf_context": "H1 sweeping recent high (4202) and strongly rejecting, bearish bias",
    "m30_structure": "Bearish engulfing/drop after sweeping highs",
    "m15_m5_execution": "M5 shows a peak at 4202 followed by strong downside close (4195, 4183). No long entry criteria met.",
    "entry": None,
    "stop": None,
    "target": None,
    "r": None,
    "promoted_to_journal": False
})

results.append({
    "candidate_id": "candidate_2026-07-06T03-30-00Z_short_liquidity_sweep_reversal",
    "timestamp": "2026-07-06T03:30:00Z",
    "decision": "needs_more_context",
    "reason": "Bearish continuation, but M5 entry lacks a distinct liquidity sweep and clear FVG/OB confirmation at 03:30",
    "htf_context": "H1 strongly bearish, dropping from 4202 to 4160s",
    "m30_structure": "Consistent lower highs and lower lows",
    "m15_m5_execution": "M5 shows a minor pullback to 4167.6 but lacks clear SMC entry mechanics (no strong sweep or defined FVG)",
    "entry": None,
    "stop": None,
    "target": None,
    "r": None,
    "promoted_to_journal": False
})

results.append({
    "candidate_id": "candidate_2026-07-06T07-00-00Z_long_liquidity_sweep_reversal",
    "timestamp": "2026-07-06T07:00:00Z",
    "decision": "needs_more_context",
    "reason": "M5 forms a higher low at 4147.2 but lacks clear chronological CHoCH and Fib 50/62 entry confirmation prior to expansion",
    "htf_context": "H1 bearish trend exhausting around 4145, attempting reversal",
    "m30_structure": "Consolidating near lows before bullish push at 07:30",
    "m15_m5_execution": "M5 sweeps 4148 internally but expansion to 4164 occurs without clear pullback entry opportunity",
    "entry": None,
    "stop": None,
    "target": None,
    "r": None,
    "promoted_to_journal": False
})

out_file = "/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_results/replay_result_00748_00751.json"
with open(out_file, 'w') as f:
    json.dump(results, f, indent=2)
print(f"Results written to {out_file}")

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

# The file schema has a nested 'cursor' object
prog['cursor']['next_index'] = 751
prog['cursor']['processed_count'] = 751
prog['cursor']['rejected_count'] += 1
prog['cursor']['needs_more_context_count'] += 2
prog['cursor']['last_candidate_id'] = "candidate_2026-07-06T07-00-00Z_long_liquidity_sweep_reversal"
prog['cursor']['last_updated'] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')

prog['runs'][0]['result_files'].append("hybrid/reviews/manual_replay_results/replay_result_00748_00751.json")
prog['runs'][0]['decision_counts']['rejected'] += 1
prog['runs'][0]['decision_counts']['needs_more_context'] += 2
prog['runs'][0]['derived_at'] = prog['cursor']['last_updated']

with open(prog_file, 'w') as f:
    json.dump(prog, f, indent=2)
print("Progress updated.")

