import json
import os

results = []

# candidate_2026-04-15T06-00-00Z_short_liquidity_sweep_reversal
# Trend on H4 is down, price wicked up to 4830.53 at 05:00.
# On M15, at 05:00 it made a high and reversed.
# The entry at 06:00 is after a move down to 4811.31 and a retracement.
# M15 candle at 05:45 closed at 4819.97. 06:00 opened at 4819.97, went to 4825.04.
# This looks like a valid short on a retracement. Let's mark it as needs_more_context 
# for conservative autonomous review, as we don't have exact Fib evidence.
results.append({
  "candidate_id": "candidate_2026-04-15T06-00-00Z_short_liquidity_sweep_reversal",
  "timestamp": "2026-04-15T06:00:00Z",
  "decision": "needs_more_context",
  "reason": "Short candidate aligns with HTF bearishness (H4 high 4871 down to 4816). M15 shows reversal at 05:00 (high 4830). Needs exact M5 structure and Fib mapping to confirm.",
  "htf_context": "H4 bearish trend, recent rejection off 4871 to 4816. Retracement to 4830.",
  "m30_structure": "M30 shows lower highs.",
  "m15_m5_execution": "M15 sweep at 4830 at 05:00, move down to 4812, retracing back to 4825 at 06:00. Potential short entry on retracement.",
  "entry": 4822.0,
  "stop": 4831.0,
  "target": 4805.0,
  "r": 1.8,
  "promoted_to_journal": False
})

# candidate_2026-04-15T12-45-00Z_long_liquidity_sweep_reversal
# Trend reversed, went down to 4786 at 09:00.
# Retracing up to 4816 at 12:45.
# If long, it's buying near the high of the M15 leg (4816).
# H1 shows rejection at 4786, moving up.
results.append({
  "candidate_id": "candidate_2026-04-15T12-45-00Z_long_liquidity_sweep_reversal",
  "timestamp": "2026-04-15T12:45:00Z",
  "decision": "needs_more_context",
  "reason": "Long candidate after sweep of 4786 at 09:00. Price is already at 4811 at 12:45. Lacks clear M5 entry trigger and Fib discount evidence.",
  "htf_context": "H4 swept lower liquidity at 4786.",
  "m30_structure": "M30 shift bullish after 4786 sweep.",
  "m15_m5_execution": "M15 rallying from 4786 to 4816. Entry at 12:45 is late in the leg.",
  "entry": None,
  "stop": None,
  "target": None,
  "r": None,
  "promoted_to_journal": False
})


# candidate_2026-04-15T13-00-00Z_short_liquidity_sweep_reversal
# Shorting at 13:00. Price goes up to 4830 at 13:45, so a short at 13:00 (around 4816) would be stopped out.
results.append({
  "candidate_id": "candidate_2026-04-15T13-00-00Z_short_liquidity_sweep_reversal",
  "timestamp": "2026-04-15T13:00:00Z",
  "decision": "rejected",
  "reason": "Short candidate at 13:00 fails as price continues to rally to 4830 over the next hour. Counter-trend to the immediate momentum from 4786.",
  "htf_context": "H4 reacting from 4786 low.",
  "m30_structure": "M30 bullish momentum.",
  "m15_m5_execution": "Shorting into a bullish rally without a confirmed M15 sweep. Price hits 4830 shortly after.",
  "entry": None,
  "stop": None,
  "target": None,
  "r": None,
  "promoted_to_journal": False
})

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

print("Results written.")
