# Bot Operating Rules

These rules are mandatory before changing live strategy, prompt, target, stop,
risk, or execution behavior.

## Replay Before Live

Before restarting or reloading the live bot after a behavior change:

1. Run a replay against the relevant recent loss trades and at least one recent
   winner.
2. Include the old trade, new decision, fill result, TP/SL outcome, and net PnL
   estimate in a report under `data/reports/`.
3. If the replay only shows fewer bad trades but no better entry/target behavior,
   say that explicitly. Do not present it as a strategy improvement.
4. Do not use "it compiled" or a single smoke test as proof that the bot trades
   better.

Standard commands:

```bash
set -a; [ -f /run/hl-bb-live.env ] && . /run/hl-bb-live.env; set +a
.venv/bin/python scripts/loss_diagnosis.py --since '<timestamp>' --interval 1m --missed-candidates 10 --missed-lookahead-hours 4
.venv/bin/python scripts/replay_current_brain.py --config config.toml --since '<timestamp>' --limit 8 --horizon-hours 8 --out data/reports/current-brain-replay-latest.md
```

## What Counts As Evidence

- Good evidence: same historical snapshots replayed with the current brain,
  showing whether the bot would enter, wait, hit TP, hit SL, or avoid a loser.
- Weak evidence: compile success, one synthetic unit test, or "the prompt looks
  better".
- If the goal is better direction and TP selection, the report must show target
  prices and OHLC follow-through, not only fewer entries.

## Live Service

- Editing code does not affect the running bot until `hl-bot-v2-live.service`
  is restarted.
- Before restart, check whether there are open positions and mention them.
- Do not manually close positions unless explicitly requested.
