# CRE v1.0 — Build Handoff (for the continuing agent) **Status:** Steps 0–3 complete & verified. Step 4 (dashboard UI) is a skeleton only. **Read first:** `CRE Agent Build Log.md` (full decision history, Entries 001–011) and `confluence-reversal-engine-spec.md` is the original blueprint (in the parent `web/` dir; copy is the source of truth for strategy logic). --- ## What works today (verified) | Area | File(s) | State | |------|---------|-------| | Config + version-controlled thresholds | `config.py` (CONFIG_VERSION=3) | ✅ | | OKX data client (funding/OI/klines/taker/liq WS) | `exchange/okx.py`, `exchange/base.py` | ✅ live-probed | | Dynamic universe funnel | `universe.py` | ✅ | | SQLite store + schema (spec §9) + self-baselines | `store/db.py` | ✅ | | Data workers (universe/liq/poller) | `workers.py` | ✅ | | Engine: 4 layers, confluence, conviction, levels | `engine/layers.py`, `engine/scoring.py` | ✅ 42 tests pass | | Lifecycle state machine | `engine/lifecycle.py` | ✅ | | Risk (cooldown gate, no caps — conviction ranks) | `engine/risk.py` | ✅ | | Signal engine + active monitor | `signals_worker.py` | ✅ synthetic e2e | | Telegram alerts | `alerts/telegram.py` | ✅ format verified | | HF bucket persistence (restore/sync) | `sync.py` | ✅ structure (live on HF) | | App entrypoint + boot wiring | `app.py` | ✅ boots, placeholder UI | | Per-pair links (TV + symbol helpers) | `links.py` | ✅ | | Tests | `tests/test_engine.py` | ✅ 42/42 | Run tests: `cd && python tests/test_engine.py` Boot locally: `pip install -r requirements.txt && python app.py` (OKX needs non-US IP). --- ## What REMAINS (priority order) ### 1. Step 4 — Dashboard UI ← main remaining work `ui/dashboard.py` currently is a **skeleton stub** (see file header). Build the real one to the design brief (Build Log Entry 003 + D10): - Dark theme, **Nunito** font, SVG logo + uniform SVG animations, `Ver. 1.0` tag, live status badges, Title Case labels, fully responsive. - **4 tabs:** Signals (ranked by conviction, colored tags 🟣🟢🟡⚪, Chart + TV links), Market (funding/OI/liq per universe coin), Performance (win rate / avg R / equity curve in R, from `signals` table — spec §7), Health (ws uptime, last poll, baseline coverage days/7, DB size, config version). - **Live updates via `gr.Timer`** (no page refresh — D10). Read latest state from `store/db.py` query helpers; `app.py` already lazy-imports `ui.dashboard.build(get_state)` and falls back to the placeholder if absent — so just implement `build(get_state)` returning a `gr.Blocks`. - Data already available: `db.recent_signals()`, `db.active_signals()`, `db.latest_snapshots()`, `db.liq_baseline_days()`, plus `signals` rows carry conviction fields needed for tags. ### 2. Step 4b — Annotated "Chart" screenshots (D7) `matplotlib`+`mplfinance` already in requirements. Build `chart.py`: render a candlestick PNG for a signal marking FVG boxes, swing H/L, BoS line, entry/stop/T1/T2. Surface as the "Chart" link/button per signal in the Signals tab. (TV link already done in `links.py`.) ### 3. Conviction persistence gap (small, do early) `signals` table stores `score_*` + levels but NOT `conviction`/`conviction_tag` as columns (they're computed in `engine/scoring.py`). For the dashboard tags to survive restart, either (a) add `conviction REAL, conviction_tag TEXT` columns to the schema in `store/db.py` + `insert_signal`, OR (b) recompute on read. Recommend (a) — one ALTER + 2 dict keys. ### 4. Step 5 — SKILL.md (installable blueprint) Use the skill-export procedure to produce an installable `SKILL.md` capturing the whole strategy + build. Not yet started. ### 5. Step 6 — Final packaging Re-zip as `Confluence Revesal Crypto Engine v1.0.zip` (user's exact filename, note the original spelling) after testing + final go. ### 6. Live validation on HF (only possible there) - OKX REST from a non-US node (this build box + HF default are geo-blocked from Binance/Bybit; OKX worked from here, but confirm on the actual Space). - Bucket restore/sync round-trip with real `HF_TOKEN` + `CRE_BUCKET`. - 7-day liquidation baseline accumulation (cold start → WATCH-only until mature). --- ## Key decisions already locked (don't re-litigate — see Build Log) - **D1** Gradio SDK (not Docker) · **D4** OKX sole data source (Binance/Bybit removed, geo-blocked) - **D5** dynamic whole-market universe via liquidity funnel, event-driven on flushes - **D6** CoinGecko = enrichment/price-redundancy only (cannot power signals) - **D7** per-signal TV link (`TV_EXCHANGE` var, default BYBIT) + annotated Chart screenshot - **D8** Telegram token+chat id = HF **Secrets** (encrypted) - **D9** persistence = HF Storage Bucket snapshot/restore (NOT direct mount — SQLite locking) - **D10** UI live updates via `gr.Timer`, no page refresh - **Engine:** removed spec's hard active-signal caps → **Conviction Score (0..100)** ranks ALL setups + colored tag (Elite≥85/Strong≥70/Moderate≥55/Watch). Cooldown is the only hard gate. ## Env vars (HF Space) Secrets: `TELEGRAM_BOT_TOKEN`, `TELEGRAM_CHAT_ID`, `HF_TOKEN`, (opt) `COINGLASS_API_KEY`. Variables: `CRE_BUCKET`, `TV_EXCHANGE`, `DB_PATH=/data/cre.db` optional, `UNIVERSE_MAX`, `UNIVERSE_MIN_TURNOVER_USD`, `WATCHLIST` (pins fixed mode), `POLL_INTERVAL_SEC`. Full setup runbook: `HF_SETUP.md`.