# Binance Copytrader Replication Handoff

Created: 2026-06-01 UTC  
For: laptop-side successor agent repeating the Veronika HYPE path on other Binance copytrader channels.

## Read First

Governance and environment:

```bash
/var/www/vps2.happyuser.info/top/.codex_CLI_laptop_local_philosofy/PHILOSOPHY.md
/var/www/vps2.happyuser.info/top/.codex_CLI_laptop_local_philosofy/AGENT_GOVERNANCE.md
/var/www/vps2.happyuser.info/top/.codex_CLI_laptop_local_philosofy/ENVIRONMENT_POLICY.md
/var/www/vps2.happyuser.info/top/.codex_CLI_laptop_local_philosofy/VERONIKA_TO_VERONIKA2_HANDOFF_20260526.md
/var/www/vps2.happyuser.info/top/veronika/docs/AGENT_GIT_WORKTREE_POLICY.md
```

On VPS before Python/tools/tests:

```bash
source /var/www/vps2.happyuser.info/top/.codex_CLI_laptop_local_philosofy/profiles/top_1.server.sh
python --version
```

Laptop agents must use the laptop profile/runtime, not copied VPS venvs or VPS agent resume ids.

Hard safety boundary:

- Do not place live orders without explicit human approval for that exact step.
- Do not read or print secrets or `.env` values unless the human explicitly approves and the task requires it.
- Do not restart live, paper-live, or monitor processes from this handoff.
- Do not delete runtime state.
- Keep raw loops, NPZs, reports, live/paper-live state, and private runtime artifacts out of `dev`.

## What Veronika Achieved

The HYPE path moved from source discovery to a guarded live canary:

1. Public Binance copytrader source positions were collected and normalized from public lead endpoints.
2. HYPE source-position state was converted into explicit strategy intents: open from source open, DCA from champion policy, close from validated source close/history.
3. Candidate 189 became a reusable DCA policy module instead of hardcoded runner behavior.
4. Paper-only/live-disabled canary proved the policy loop could run without an order path and with absolute capital guards.
5. Exchange live canary wrapper added a broker boundary: auth probe, stable client order IDs, precision/min-order preflight, open/close submission, exchange position sync, session DB, telemetry, status files, hot-stop/restart snapshots.
6. Monitor/alert tests covered stale status, rejected-order clusters, repeated close/open attempts, historical rejected-order dedupe, exchange mismatch, stale DB row filtering, and notional mismatch.
7. Responsibility was clarified: strategy is the trader; live runner is only broker/market-maker execution machinery.

Observed HYPE live result from Veronika handoff: the runner detected the Binance copy source close via history and closed the BingX long with `FILLED` status at `2026-05-26T12:31:16.594828Z`. Treat that as evidence to inspect, not a reusable launch permission.

## File Map

Source ingestion and canonicalization:

- `obw_platform/meta_strategies/telegram_signal_dca/paper_live_binance_copy_public_positions.py`
  - public Binance copy open positions/history polling;
  - normalizes symbol, side, entry, mark, open/close timestamps, avg cost/avg close;
  - read-only; no order submission.
- `obw_platform/meta_strategies/binance_online_copytrading/binance_online_copytrading.py`
  - broader public copytrading paper/shadow runner for multiple leads.
- `reports/binance_copy_4751838302089254401_20260519/REPORT.md`
  - early contrarian-on-close evidence: 47 normalized/tested positions; DCA variants improved net and DD versus plain.

Meta-strategy from source state to intent:

- `obw_platform/meta_strategies/telegram_signal_dca/hype_copy_signal_meta_strategy.py`
  - filters source positions;
  - validates source history matches with open/close tolerances;
  - emits explicit `open_entry`, `dca_entry`, and `close_position` intents;
  - close policy is explicit: `source_close_closes_follower`.

Champion DCA policy:

- `obw_platform/meta_strategies/telegram_signal_dca/hype_cap100_champion_dca_strategy.py`
  - candidate 189 params;
  - DCA drops, multipliers, base/add notionals, levels;
  - owns trading policy and emits order-intent dictionaries.
- `reports/hype_canary_smoke_20260525/RUNBOOK.md`
  - candidate 189 smoke selection and safety interpretation.
- `docs/optimization/HYPE_VERONICA_OPTIMIZATION_ACCELERATION_PLAN.md`
  - acceleration and search policy; Python replay remains the reference until Numba equivalence passes.

Paper/live-disabled and live canary boundary:

- `obw_platform/meta_strategies/telegram_signal_dca/hype_cap100_live_disabled_canary.py`
  - paper-only runner by construction;
  - no exchange order submission path;
  - applies strategy intents with paper fills, slippage, caps, daily loss guard, deadline, and max order rate.
- `obw_platform/meta_strategies/telegram_signal_dca/hype_cap100_bingx_live_canary.py`
  - exchange canary wrapper;
  - broker duties: auth probe, exchange profile/defaults, preflight, stable client order IDs, submit open/close, safe order logging, exchange position sync, state/status/telemetry/session DB, hot-stop/restart snapshot.
  - do not generalize to new capital until the same gates pass for the new channel/symbols.

Runner/broker execution layer:

- `obw_platform/runners/live_runner_dual_responsibility_map.md`
  - canonical statement of responsibility split.
- `obw_platform/runners/strategy_intents.py`
  - typed `ExecutionIntent`, strategy-owned rejection backoff, entry/manage intent normalization.
- `obw_platform/runners/live_runner_dual.py`
  - production broker/execution adapter for the dual-strategy path: symbol resolution, CCXT orders, precision, fill polling, cancellation, rollback, reconciliation, telemetry, heartbeat, stop guard.
- `obw_platform/runners/virtual_exchange.py`
  - replay/preflight exchange with OHLCV NPZ/DB input, fills, rejections, state, fees, slippage, and broker-like interface.

Monitor/telemetry:

- `obw_platform/meta_strategies/telegram_signal_dca/live_session_telegram_monitor.py`
  - reads live dir status/session DB/process state and sends deduped Telegram alerts.
- Runtime artifacts to inspect, not commit:
  - `RUN_STATUS.json`
  - `run_state_*.json`
  - `run_telemetry_*.jsonl`
  - `session.sqlite`
  - `live_equity.csv`, `live_candles.csv`, `live_chart_events.*`, `live_strategy_params.json`

Key tests:

```bash
python -m unittest obw_platform.tests.test_live_runner_strategy_intents
python -m unittest obw_platform.meta_strategies.telegram_signal_dca.test_hype_strategy_runner_split
python -m unittest obw_platform.meta_strategies.telegram_signal_dca.test_hype_cap100_bingx_live_canary
python -m unittest obw_platform.meta_strategies.telegram_signal_dca.test_hype_cap100_live_disabled_canary
python -m unittest obw_platform.meta_strategies.telegram_signal_dca.test_live_session_telegram_monitor
```

## Philosophy Constraint

The strategy is the trader.

The live runner is the broker/market-maker executor. It may:

- resolve symbols;
- normalize precision/min order;
- apply venue parameters;
- submit/cancel/poll orders;
- reconcile open orders, fills, and positions;
- persist state and telemetry;
- block unsafe execution because of venue/control constraints.

It must not invent trading policy:

- no runner-created open signals;
- no runner-created TP/SL/DCA/close rules;
- no hidden retry storm logic that bypasses strategy backoff;
- no fallback from limit to market unless the strategy intent/policy explicitly allows it;
- no close on source disappearance unless the meta-strategy emitted an explicit close intent.

Tests that encode this split:

- `test_strategy_entry_signal_is_the_only_open_source`
- `test_live_runner_does_not_close_without_strategy_close_intent`
- `test_live_executor_stops_dca_intents_after_first_blocked_dca`
- `test_strategy_owned_backoff_blocks_retry_storms_and_resets_on_fill`

## Replication Sequence For A New Binance Copytrader

Use a new owner branch/worktree for non-trivial work. Start with analysis-only and paper-only modes.

1. Collect and canonicalize signals.
   - Identify the Binance `portfolioId`.
   - Poll public open positions and position history.
   - Normalize to stable rows: `key`, source position id, symbol, side, entry, mark, opened/closed UTC, avg cost, avg close.
   - Save raw pages plus normalized CSV/JSON under a report path, not runtime state.
   - Reject rows with missing symbol/side/entry, unknown side, impossible timestamps, or no executable market mapping.

2. Build source-signal evidence.
   - Produce a compact report like `reports/binance_copy_4751838302089254401_20260519/REPORT.md`.
   - Separate signal modes: follow open, contrarian on close, long-only/short-only, source-close-following, autonomous exits.
   - Do not use Binance lead `avgCost`/`avgClosePrice` as promotion fills. They are artifact baselines only.

3. Paper/replay with executable fills.
   - Use first/next bar open, live paper snapshot entries, or virtual exchange fills.
   - Include slippage, fees, min-order gate, unlevered capital grounding, drawdown, MTM tail risk, and notional > equity checks.
   - Keep Python/exact replay as reference. Accelerated engines are usable only after equivalence passes.

4. Prove backtest/live equivalence.
   - Strategy code must be the same policy surface used by paper and live wrappers.
   - Meta-strategy emits explicit intents.
   - Runner only consumes intents.
   - Compare paper theoretical fills vs exchange/virtual fills.

5. Preflight with virtual exchange and restart evidence.
   - Run against `obw_platform/runners/virtual_exchange.py`.
   - Inject rejects/timeouts/open-order restart scenarios.
   - Verify stable client order IDs, no duplicate entries after restart, pending orders reconciled, and state snapshots recover.
   - Confirm `STOP_NEW_ORDERS`, `KILL`, and hot-stop controls are recognized.

6. Live-disabled canary.
   - Use a paper-only wrapper with no `create_order` path.
   - Enforce absolute caps before every base/DCA entry:
     - max gross notional;
     - max one-side notional;
     - max daily realized + unrealized loss;
     - max new orders per hour;
     - runtime deadline;
     - source freshness/delay.
   - Exits/reduces may remain allowed when they reduce risk.

7. Shadow/dry-order exchange validation.
   - Auth probe may confirm credentials presence/permissions without printing secrets.
   - Validate exchange, symbol, precision, min qty/notional, position mode, reduce-only/hedged params, and client order ID constraints.
   - Write desired orders/shadow orders; do not submit.

8. Small canary live.
   - Requires explicit human approval.
   - Use non-withdrawal API key, IP whitelist, hard caps, kill switch, no auto-restart, and dedicated runtime dir.
   - Start with tiny capital and single source/symbol policy.
   - Monitor from the first minute.

9. Monitor and telemetry gates.
   - `RUN_STATUS.json` fresh within threshold.
   - No rejected-order cluster.
   - No repeated open/close attempts for the same action.
   - No stale DB rows from other bot/exchange/path included in live notional.
   - No exchange mismatch.
   - No source/history mismatch beyond tolerance.
   - No unreviewed control flags/backoff active.

10. Scale-up criteria.
   - Several weeks profitable paper/shadow/live-small evidence.
   - Clean restart evidence.
   - Clean monitor history.
   - Slippage within configured bp gates.
   - Drawdown and daily loss within contract.
   - No duplicate entries, missed closes, or policy/runner responsibility violations.
   - Human-approved capital step with rollback plan.

## Failure Modes And Safeguards Added

Repeated order POST storm after rejects:

- Strategy-owned `StrategyRejectionBackoff` in `obw_platform/runners/strategy_intents.py`.
- Live canary tracks order error backoff/circuit and entry failure cooldown.
- Monitor detects rejected-order clusters and repeated attempts.

Close/open exchange parameter errors:

- `live_order_params()` handles position mode/exchange differences.
- BingX hedge mode uses CCXT `hedged=True`; Gate.io uses safe `text` client field.
- Close handles no-position/reduce-only errors as sync-only where appropriate.

Stale DB rows causing false alarms:

- Monitor filters position/notional checks by current live dir bot id and expected exchange.
- Tests cover stale other-exchange and other-bot rows.

Historical rejected orders causing repeated alerts:

- Monitor baseline/seen-order state dedupes old fills/rejects.
- `--init-baseline` marks existing orders without alerting.

Source close vs own TP/DCA policy mismatch:

- Source close is now an explicit meta-strategy close intent, not runner inference.
- HYPE champion DCA policy remains in `hype_cap100_champion_dca_strategy.py`.
- Future channels must decide whether source close always wins, whether autonomous TP/SL/TTL wins, or whether those are separate strategies. Do not mix them silently.

Live/backtest responsibility split:

- `live_runner_dual_responsibility_map.md` documents broker vs strategy ownership.
- Tests enforce no open/close without explicit strategy/meta-strategy intent.

## Checklist Before New Live Capital

- Read the governance files and activate the correct local environment.
- Confirm branch/worktree owner and keep runtime artifacts out of `dev`.
- Identify source `portfolioId`, symbols, and signal mode.
- Save raw and normalized source evidence.
- Produce a report with counts, period, trade count, net, PF, max DD, skips, and assumptions.
- Use executable fill sources only for promotion evidence.
- Split train/validation/holdout by trades/signals; do not tune on holdout after failure.
- Verify exact replay and any accelerated replay equivalence.
- Extract trader policy into a module; do not hardcode strategy policy in runner.
- Add tests proving paper/live wrappers consume the same meta-strategy and policy modules.
- Run virtual exchange preflight with rejects, restarts, no-position close, and pending-order scenarios.
- Run live-disabled canary with hard caps and no order path.
- Run monitor dry-run and baseline initialization.
- Verify status/session DB/telemetry are fresh and scoped to the new runtime dir.
- Get explicit human approval before any real exchange submit path.
- For live-small: use tiny capital, non-withdrawal key, IP whitelist, kill switch, no auto-restart, and a rollback/stop plan.

## Open Questions And Risks Before Scaling

- Which source-close semantics should each new channel use: source-close-follows, autonomous exit, or separate strategy families?
- How stable are Binance public copy endpoints and fields across lead pages?
- Are source position IDs stable enough for deterministic client order IDs and history matching on every lead?
- Can multi-symbol channels preserve the same notional, DCA, and daily loss gates without hidden correlation risk?
- `live_runner_dual.py` remains large; exchange adapter, telemetry, and bar loop are not physically split.
- Pending-order restart lifecycle is improved but still needs richer DB-backed accounting before larger capital.
- Slippage calibration from HYPE does not automatically transfer to other symbols/exchanges.
- Monitor alerts are necessary but not sufficient; a human must review early live-small incidents before scaling.
- Laptop/server parity must be proven per OS. Do not assume VPS paths, venvs, or tmux/session state exist on laptop.

## Minimal Command Shapes

Read-only source poll/backfill shape:

```bash
python obw_platform/meta_strategies/telegram_signal_dca/paper_live_binance_copy_public_positions.py \
  --portfolio-id <BINANCE_PORTFOLIO_ID> \
  --report-dir reports/binance_copy_<id>_<date> \
  --once
```

Smoke the responsibility split:

```bash
python -m unittest \
  obw_platform.tests.test_live_runner_strategy_intents \
  obw_platform.meta_strategies.telegram_signal_dca.test_hype_strategy_runner_split
```

Smoke the HYPE canary and monitor surfaces before copying patterns:

```bash
python -m unittest \
  obw_platform.meta_strategies.telegram_signal_dca.test_hype_cap100_bingx_live_canary \
  obw_platform.meta_strategies.telegram_signal_dca.test_hype_cap100_live_disabled_canary \
  obw_platform.meta_strategies.telegram_signal_dca.test_live_session_telegram_monitor
```

Virtual exchange preflight shape:

```bash
VIRTUAL_EXCHANGE_NPZ=<path-to-ohlcv.npz> \
VIRTUAL_EXCHANGE_SYMBOLS=<SYMBOL/USDT:USDT> \
VIRTUAL_EXCHANGE_ERRORS_JSON='{"reject_next_n_orders":1}' \
python <preflight_or_scenario_runner.py>
```

Do not convert any of these command shapes into live order submission without a new, explicit human instruction.
