feat: Phase 2 + context log — FRED releases, cycle context snapshot, onglet Contexte IA

Phase 2 — Données macro FRED :
- fred_fetcher.py (nouveau) : 7 séries FRED (CPI, NFP, UNRATE, FEDFUNDS, GDP, ICSA,
  spread 10Y-2Y) avec détection direction bullish/bearish et block prompt formaté
- ai_analyzer.py : param fred_block dans suggest + score, injecté dans les deux prompts
- auto_cycle.py : fetch FRED non-bloquant avant la suggestion

Context log — Snapshot du contexte complet :
- database.py : table cycle_context_snapshots + save/get/list fonctions
- auto_cycle.py : sauvegarde le snapshot (meta, news partitionnées, FRED, tech, IV, quotes)
- cycle.py : GET /api/cycle/contexts + GET /api/cycle/contexts/{run_id}
- useApi.ts : hooks useCycleContextSnapshots + useCycleContextSnapshot
- SystemLogs.tsx : onglet "Contexte IA" avec liste de cycles et visualiseur JSON
  par section (cycle_meta, macro, news, FRED, tech) avec accordéon

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-20 16:51:02 +02:00
parent 50ba75e468
commit 9c0ebbd138
7 changed files with 451 additions and 13 deletions

View File

@@ -867,6 +867,21 @@ export const useClearLogs = () =>
mutationFn: (days: number) => api.delete('/logs/clear', { params: { older_than_days: days } }).then(r => r.data),
})
export const useCycleContextSnapshots = (limit = 30) =>
useQuery({
queryKey: ['cycle-context-snapshots'],
queryFn: () => api.get('/cycle/contexts', { params: { limit } }).then(r => r.data),
staleTime: 30_000,
})
export const useCycleContextSnapshot = (runId: string | null) =>
useQuery({
queryKey: ['cycle-context-snapshot', runId],
queryFn: () => api.get(`/cycle/contexts/${runId}`).then(r => r.data),
enabled: !!runId,
staleTime: 300_000,
})
// ── IV Watchlist Management ───────────────────────────────────────────────────
export const useWatchlistTickers = () =>