feat: AI-enriched news scoring + directional alignment on pattern matching

Hook ai_score_news_batch() into /api/geo/news so every news fetch is enriched
by GPT-4o-mini: corrected impact_score, ai_dir_energy/metals/indices, ai_resolution
(ceasefire/peace deal flag), ai_insight (1 French sentence). Gracefully no-ops
when OpenAI is not configured.

Add _compute_ai_alignment() in geo_analyzer: for each pattern compares the news
AI directional signals against the pattern's expected_move direction and produces
a -25..+25 bonus injected into similarity/relevance scores. Contra-signals
(e.g. peace deal → oil bearish while pattern expects oil spike) are flagged.

Frontend GeoRadar: PatternRelevanceCard shows AI alignment badge (green = aligned,
red = contra-signal) + base relevance diff + AI insights. NewsCard shows ai_insight,
directional arrows per asset class (🥇↓) and resolution badge when expanded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-19 12:57:52 +02:00
parent 44ada3f8f1
commit 0ee9cf5707
3 changed files with 127 additions and 4 deletions

View File

@@ -17,6 +17,14 @@ def geo_news(force_refresh: bool = False):
if not force_refresh and _news_cache["data"] and (now - _news_cache["ts"]) < 3600:
return _news_cache["data"]
news = fetch_geo_news()
# Enrich with AI: corrects impact_score, adds ai_dir_energy/metals/indices,
# ai_resolution (ceasefire/peace deal), ai_insight (1 French sentence).
# Gracefully skips if OpenAI not configured.
try:
from services.ai_analyzer import ai_score_news_batch
news = ai_score_news_batch(news)
except Exception:
pass
_news_cache["data"] = news
_news_cache["ts"] = now
return news