import json
import os

results = []
candidates = [
    {
        "id": "candidate_2026-04-29T11-00-00Z_short_liquidity_sweep_reversal",
        "time": "2026-04-29T11:00:00Z",
    },
    {
        "id": "candidate_2026-04-29T12-15-00Z_short_liquidity_sweep_reversal",
        "time": "2026-04-29T12:15:00Z",
    },
    {
        "id": "candidate_2026-04-29T12-45-00Z_short_liquidity_sweep_reversal",
        "time": "2026-04-29T12:45:00Z",
    }
]

# Shared analysis for this sequence
htf_context = "H4 shows a sharp decline from 4700 on 4/27 down to 4555 on 4/28, then a bounce to 4610 on 4/28 evening. Since 4/29 01:00 (4605), price is bleeding heavily downward. H4 bias is strongly bearish in a retracement/impulse leg. M30 shows lower highs and lower lows from 4610, establishing a clean bearish structure."

# Review candidate 1: 11:00
# M15 high at 10:30 is 4576.535.
# At 11:00, M15 candle opens 4569.945, highs to 4572.2, closes 4568.005.
# M5 shows price drifting up to 4572.20 at 11:00 and rejecting to close 4568.31, but it didn't sweep the prior M15 structural high of 4576.53.
results.append({
    "candidate_id": candidates[0]["id"],
    "timestamp": candidates[0]["time"],
    "decision": "rejected",
    "reason": "No meaningful liquidity sweep. The high at 11:00 (4572.2) failed to take out the recent structural M15 high (4576.5) or even the M5 high at 10:30 (4576.5).",
    "htf_context": htf_context,
    "m30_structure": "Bearish trend with immediate resistance around 4576-4580.",
    "m15_m5_execution": "Price pushed up slightly to 4572.2 but reversed without sweeping key liquidity. Too shallow for a high-probability sweep setup.",
    "entry": None,
    "stop": None,
    "target": None,
    "r": None,
    "promoted_to_journal": False
})

# Review candidate 2: 12:15
# M15 at 12:00 closed at 4564.68. M15 at 12:15 opens 4564.70, highs to 4569.155, then closes 4559.555.
# This sweeps the 11:45-12:00 cluster highs (~4568.42) but again doesn't reach the major structural high of 4572 or 4576.
# It's a minor internal sweep.
results.append({
    "candidate_id": candidates[1]["id"],
    "timestamp": candidates[1]["time"],
    "decision": "rejected",
    "reason": "Minor internal sweep (4569.1) of the immediate M15 cluster, but failed to reach the deeper premium zones or sweep the major 4572/4576 highs. Choppy price action.",
    "htf_context": htf_context,
    "m30_structure": "Bearish, chopping lower. Immediate resistance cluster ~4568-4572.",
    "m15_m5_execution": "M15 spiked to 4569.155 sweeping immediate preceding candles but lacked conviction and didn't test deeper premium.",
    "entry": None,
    "stop": None,
    "target": None,
    "r": None,
    "promoted_to_journal": False
})

# Review candidate 3: 12:45
# M15 at 12:30 opens 4559.52, highs 4559.86, closes 4557.62.
# M15 at 12:45 opens 4557.58, highs 4560.21, closes 4544.945 (huge breakdown).
# M5 shows 12:45 pushed to 4560.21, then dumped hard.
# The high of 4560 barely swept the 12:30/12:40 highs of 4559.86. Very micro sweep. Not a structural sweep.
results.append({
    "candidate_id": candidates[2]["id"],
    "timestamp": candidates[2]["time"],
    "decision": "rejected",
    "reason": "This is a momentum breakdown rather than a liquidity sweep reversal setup. The 'sweep' was a micro 5m wick of the immediate previous candle before a massive dump. Does not fit the sweep reversal playbook.",
    "htf_context": htf_context,
    "m30_structure": "Bearish breakdown accelerating downward.",
    "m15_m5_execution": "Price made a micro wick to 4560.21 before collapsing 150 pips. Not a tradable sweep setup.",
    "entry": None,
    "stop": None,
    "target": None,
    "r": None,
    "promoted_to_journal": False
})

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

print(f"Wrote {len(results)} results to {out_path}")
