feat(gui+infra): pagina Strategia, P/L parametrico, profili Conservativa/Aggressiva, dashboard via Traefik

Espone la GUI Streamlit su https://cerbero-bite.tielogic.xyz tramite il
Traefik già attivo sull'host (label allineate al pattern di cerbero-mcp,
TLS via Let's Encrypt, websocket pass-through). Aggiunge:

- nuova tab `📚 Strategia` con stato live dei gate §2 confrontati con
  l'ultimo tick di market_snapshots, pannello P/L parametrico
  affiancato Conservativa vs Aggressiva, tabella di sensibilità
  win-rate → APR e rendering del documento canonico esteso.
- doc `13-strategia-spiegata.md` che lega ogni regola §2-§9 al campo di
  market_snapshots che la alimenta, con sezioni §4-bis (P/L atteso
  realistico, win-rate empirico, drawdown, Sharpe) e §4-ter (confronto
  fra i due profili e quando passare dall'uno all'altro).
- `strategy.conservativa.yaml` (golden config v1.0.0 esplicita) e
  `strategy.aggressiva.yaml` (cap_per_trade 4×, max_concurrent 2×,
  max_contracts 4×, deroga §11 documentata) con config_hash validi.
- nel compose: servizio dedicato `cerbero-bite-gui` (Streamlit su
  0.0.0.0:8765, healthcheck su /_stcore/health, label Traefik), env
  condivisi via anchor YAML `x-bite-env`, `--environment mainnet`
  passato a `start` per allineare il boot check al token del .env (era
  testnet vs mainnet → kill switch armato all'avvio).
- Dockerfile installa anche l'extra `gui` (streamlit) e copia
  `docs/` + i due nuovi profili nell'immagine; `.dockerignore` non
  esclude più `docs/` (causa del primo build silenzioso).

Fix bonus: `_try_load` nella pagina ritornava `LoadedConfig` ma la GUI
leggeva `.sizing.*` direttamente — l'`except: pass` mascherava
l'AttributeError facendo cadere sui default conservativi sia nel
pannello P/L sia nello stato gate (stesso pattern presente nella
Calibrazione). Ora ritorna `.config`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-05-01 18:20:23 +00:00
parent ce158a92dd
commit 21e865ffb0
7 changed files with 1682 additions and 28 deletions
+8 -2
View File
@@ -14,12 +14,12 @@ ENV UV_PROJECT_ENVIRONMENT=/opt/venv \
# Install only the dependencies first so the layer is cached when the
# source tree changes.
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project
RUN uv sync --frozen --no-dev --no-install-project --extra gui
# Now copy the source tree and install the project itself.
COPY src ./src
COPY README.md ./
RUN uv sync --frozen --no-dev
RUN uv sync --frozen --no-dev --extra gui
FROM python:3.13-slim AS runtime
@@ -40,6 +40,12 @@ COPY --from=builder /opt/venv /opt/venv
COPY --from=builder /app/src /app/src
COPY scripts /app/scripts
COPY strategy.yaml /app/strategy.yaml
# Profili alternativi confrontati nella pagina "📚 Strategia".
COPY strategy.conservativa.yaml /app/strategy.conservativa.yaml
COPY strategy.aggressiva.yaml /app/strategy.aggressiva.yaml
# Documentation is shipped at runtime so the Streamlit "Strategia"
# page can render the canonical strategy doc directly.
COPY docs /app/docs
# Persistent state + audit go into /app/data, mounted as a volume in
# docker-compose.yml.