# Phase F5 — Live market engine, volume pane, alert foundation

**Base:** `v0.9.0` @ `601caca`  
**Release tag:** `v0.10.0`

## Objective

1. Provider-neutral live / near-live market engine with historical→live continuity  
2. Dedicated synchronized volume pane (real source volume + `volumeType`)  
3. Extensible alert domain model (drawing + indicator references; no notifications)  
4. Live-update readiness for existing indicators (SMA, S/R Finder 2.1)

## Non-goals (F5)

- F6 indicator migration / Trading Products UI  
- F7 alert evaluation loops, notifications, service workers  
- Deployment, Redis/Kafka/workers  
- TradingView data or scraping  

## Provider strategy

| Source | Historical (unchanged) | Live (F5) |
|--------|----------------------|-----------|
| OANDA | REST completed bars only | Server `/api/market/live/snapshot` — last candles including **forming** |
| Binance | REST klines (import) | Client public WebSocket kline stream (no API key) |

Routing via `lib/market/instruments.ts`. NAS100/XAU live only when provider returns data; otherwise **UNAVAILABLE** (no fabrication).

## Live candle lifecycle

```text
COMPLETED → stored in warehouse / historical buffer
FORMING   → updated in place on same `time` key
On close  → forming becomes completed once; next bar forms with new `time`
```

Identity: Unix seconds bar open (`ChartCandle.time`), merged with `mergeCandlesAsc` / `candleTimeKey`.

## Historical → live handoff

```text
Warehouse (or live initial) completed bars
  → mergeLiveTailSnapshot()
  → forming bar at end (optional)
  → incremental chart.update() on ticks
```

## Volume semantics

- OANDA: `tick`  
- Binance: `quote`  
- Threaded on chart bars; histogram pane uses signed color by close vs open.

## Pane architecture

Lightweight Charts multi-pane: pane 0 price (candles + overlays), pane 1 volume histogram. `ChartPaneState` remains layout metadata for future indicator panes (F6).

## Alert foundation

`lib/alerts/*` — `AlertRule`, `AlertCondition`, `AlertReference`, `AlertEvent`, `AlertEventIdentity`. Evaluation boundary interface only; chart mount not required.

## Security

OANDA token server-only. Binance public streams need no secrets. No credentials in localStorage or client bundles.

## Testing

Vitest: live merge, subscription refcount, volume preservation, alert identity. Regression: existing 59+ tests.

## Rollback

```powershell
git checkout v0.9.0
```
