feat: chatbot

This commit is contained in:
OpenSquared
2026-07-15 08:47:16 +02:00
parent da536e2638
commit ce9c0b53a9
11 changed files with 837 additions and 64 deletions

View File

@@ -87,13 +87,29 @@ def _block_tech_indicators() -> str:
def _block_wavelet_signals() -> str:
from services.database import get_latest_wavelet_signals
signals = get_latest_wavelet_signals()
if not signals:
return "## WAVELET SIGNALS\nNo wavelet signal detected yet (computed each auto-cycle)."
lines = ["## WAVELET SIGNALS (watchlist, latest cycle scan)"]
for s in signals[:20]:
lines.append(f"- {s['ticker']}: band {s['band_label']} · {s['signal_kind']} · {s['direction']} @ {s.get('price_at_signal')}")
from services.database import get_latest_wavelet_state
rows = get_latest_wavelet_state()
if not rows:
return "## WAVELET SIGNALS\nNo wavelet state computed yet (computed each auto-cycle for the watchlist instruments)."
by_ticker: Dict[str, List[Dict]] = {}
for r in rows:
by_ticker.setdefault(r["ticker"], []).append(r)
lines = ["## WAVELET SIGNALS (watchlist, latest cycle — slope/energy/ridge state + any active trigger)"]
for ticker, band_rows in list(by_ticker.items())[:12]:
lines.append(f"### {ticker}")
for r in band_rows:
tag = f" -> SIGNAL {r['signal_kind']} ({r['direction']})" if r.get("signal_kind") else ""
if r["band_label"] == "ridge":
if r.get("ridge_period_days") is not None:
lines.append(f"- ridge (cycle dominant): {r['ridge_period_days']:.1f}j{tag}")
continue
period = f"{r['period_low_days']}-{r['period_high_days']}j" if r.get("period_low_days") is not None else r["band_label"]
slope = r.get("slope")
slope_txt = f"pente {'+' if slope >= 0 else ''}{slope:.4f}" if slope is not None else "pente n/a"
energy_txt = f", energie {r['energy']:.4f}" if r.get("energy") is not None else ""
lines.append(f"- {r['band_label']} [{period}]: valeur {r.get('value')}, {slope_txt}{energy_txt}{tag}")
return "\n".join(lines)