# TradingView + ChatGPT 5.5/JARVIS Integration Plan

## Decision

Do **not** make SIGNUM the core dependency. Use ChatGPT 5.5/JARVIS with the existing direct HyperLiquid stack. TradingView becomes an authenticated signal source that is journaled and evaluated through paper/shadow first.

## Target Flow

```text
TradingView alert / internal strategy / copy-watch
  -> authenticated webhook or local signal ingestion
  -> normalized SignalEnvelope
  -> signal_journal.jsonl
  -> paper/shadow scoring
  -> ChatGPT 5.5 analyst report
  -> confirm/tiny-live only after hard gates are green
  -> direct HyperLiquid executor
```

## Safety Rules

- No TradingView alert may place a live order directly.
- Webhook ingestion is side-effect-free: validate, normalize, persist, and return an acceptance/rejection payload.
- Secrets are never stored in raw payloads or reports.
- Default mode is `paper_signal`.
- Live requires existing hard gates: clean reconcile, confirmed stops, alert delivery, loss gates, kill-switch off, and explicit live-autonomy approval.

## Implementation Phases

1. **Signal schema + journal**
   - Define `TradingViewSignal` and `SignalEnvelope`.
   - Normalize symbols such as `BTCUSDT`, `BTCUSD`, `BTC.P` to HyperLiquid coin `BTC`.
   - Persist raw and normalized signal records under runtime only.

2. **Webhook receiver**
   - Accept JSON POST payloads.
   - Require an `X-CTB-Webhook-Secret` header or a payload secret.
   - Validate strategy allowlist, coin allowlist, action, side, timestamp, and duplicate IDs.
   - Return accepted/rejected JSON with no trading side effects.

3. **Paper/shadow integration**
   - Convert accepted signals into paper/shadow candidates.
   - Track gross/net PnL, fees/slippage assumptions, block reasons, coin leakage, and strategy ID.

4. **ChatGPT 5.5 analyst job**
   - Provide only summarized, sanitized signal/performance data.
   - Ask for observation and recommendations, not direct execution.

5. **Reports**
   - Add TradingView section to the daily report: received, accepted, rejected, top reject reasons, best/worst strategy, and recommendation.

6. **Confirm/tiny-live later**
   - Promote only after 30-50+ closed paper/shadow trades and all safety gates are green.

## Initial Acceptance Criteria

- Tests prove valid alerts are accepted and invalid alerts are rejected.
- A CLI/local handler can ingest a sample TradingView payload and append to `signal_journal.jsonl`.
- The journal record explicitly shows `execution_mode=paper_signal` and `live_order_allowed=false`.
- No HyperLiquid signed action is reachable from the webhook handler.
