From 94ec73d8efcdef25e6614a241ba4799d50fffe68 Mon Sep 17 00:00:00 2001 From: alkatrazz Date: Tue, 30 Jun 2026 11:33:40 +0200 Subject: [PATCH] feat(finlab): boutons d'analyse rapide (digest/analyse/plan/fondamental/opport./alertes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Panneau « Actions rapides » sur le dashboard : 6 boutons one-click qui renvoient une analyse finlab instantanée (déterministe, gratuite, sans LLM), dans une modale. - 📊 Analyse (action sélectionnée) : technique (RSI/MACD/MM/signaux) + fondamental (PER/PEG/ROE/marges/dette/reco/cible) + plan R:R, combinés en une fiche - 📐 Plan R:R, 📈 Fondamentaux (action sélectionnée) ; 📋 Digest, 🔭 Opportunités, 🔔 Alertes (global) - Backend : endpoints /api/digest, /api/fundamentals, /api/analyze - Fix : fundamental.compare_portfolio() utilisait l'ancien schéma mono-compte (pf["positions"]) → cassé par le multi-comptes ; passe par data.portfolio_tickers() Vérifié : endpoints OK (TestClient), rendu modale au navigateur (Playwright) — fiche Analyse NVDA complète (technique + fondamental + plan). JS node --check OK. Co-Authored-By: Claude Opus 4.8 --- tools/finlab/dashboard/server.py | 34 +++++++++ tools/finlab/dashboard/static/index.html | 88 +++++++++++++++++++++++- tools/finlab/finlab/fundamental.py | 3 +- 3 files changed, 122 insertions(+), 3 deletions(-) diff --git a/tools/finlab/dashboard/server.py b/tools/finlab/dashboard/server.py index 955a366..cecc093 100644 --- a/tools/finlab/dashboard/server.py +++ b/tools/finlab/dashboard/server.py @@ -21,6 +21,8 @@ from fastapi.staticfiles import StaticFiles from finlab import ( alerts, data, + digest as digest_mod, + fundamental, indicators as ind, plan as plan_mod, scanner, @@ -168,6 +170,38 @@ def api_plan(ticker: str, capital: float = 1427.0): return _clean({"plan": p, "render": plan_mod.render(p)}) +# ── Analyses rapides (boutons one-click, finlab pur) ────────────────────────── +@app.get("/api/digest") +def api_digest(theme: str = "all", target: float = 5.0): + return {"text": digest_mod.build(theme, target)} + + +@app.get("/api/fundamentals") +def api_fundamentals(ticker: str): + return _clean({"snapshot": fundamental.snapshot(ticker)}) + + +@app.get("/api/analyze") +def api_analyze(ticker: str, capital: float = 1427.0): + """Analyse one-click d'une action : technique + fondamental + plan R:R (finlab pur).""" + out = {"ticker": ticker} + try: + out["technical"] = technical.analyze(ticker) + except Exception as e: + out["technical"] = {"error": str(e)} + try: + out["fundamental"] = fundamental.snapshot(ticker) + except Exception as e: + out["fundamental"] = {"error": str(e)} + try: + p = plan_mod.plan(ticker, capital) + out["plan"] = p + out["plan_render"] = plan_mod.render(p) + except Exception as e: + out["plan"] = {"error": str(e)} + return _clean(out) + + # ── Import de relevés (image → analysée par la Console IA) ───────────────────── IMPORTS_DIR = data.ROOT / "imports" _IMG_EXT = {".png", ".jpg", ".jpeg", ".webp", ".gif"} diff --git a/tools/finlab/dashboard/static/index.html b/tools/finlab/dashboard/static/index.html index 84d4ea6..9e4fd70 100644 --- a/tools/finlab/dashboard/static/index.html +++ b/tools/finlab/dashboard/static/index.html @@ -37,6 +37,12 @@ .atab:hover{border-color:var(--acc);color:#fff} .atab.on{background:var(--acc);border-color:var(--acc);color:#fff} .atag{font-size:11px;opacity:.85} + .qa-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px} + .btn.qa{text-align:left;padding:8px 10px;font-size:12.5px} + #resBody table{width:100%} + #resBody pre{background:var(--bg);padding:12px;border-radius:8px;white-space:pre-wrap;font-size:12.5px} + #resBody .kv{display:flex;justify-content:space-between;padding:4px 6px;border-bottom:1px solid var(--line);font-size:13px} + #resBody .kv b{color:#fff} .row .t{font-weight:600;color:#fff} .row .s{font-size:12px;color:var(--mut)} .mono{font-variant-numeric:tabular-nums} @@ -154,8 +160,20 @@ - +
+
+

Actions rapides

+
+ + + + + + +
+
Analyse / Plan / Fondamentaux → sur l'action sélectionnée (clique une ligne ou un titre). Le reste = global.
+

Alertes du jour

@@ -204,6 +222,17 @@
+ + +