feat: instrument analysis

This commit is contained in:
OpenSquared
2026-06-29 12:38:28 +02:00
parent 495ccfdee4
commit 79593a8fd3

View File

@@ -984,6 +984,9 @@ def analyze_event(body: AnalyzeRequest):
"SELECT id FROM causal_event_analyses WHERE market_event_id=? AND template_id=?",
(body.market_event_id, body.template_id),
).fetchone()
# Stocker tous les instruments analysés pour que la frise Instrument Analysis les retrouve
all_instruments_csv = ",".join(sorted(drift_by_inst.keys())) or primary_inst
if existing:
conn.execute("""
UPDATE causal_event_analyses
@@ -991,7 +994,7 @@ def analyze_event(body: AnalyzeRequest):
actual_json=?, activation_score=?, drift_json=?, analyzed_at=?
WHERE market_event_id=? AND template_id=?
""", (
primary_inst, json.dumps(inputs), json.dumps(body.coef_overrides),
all_instruments_csv, json.dumps(inputs), json.dumps(body.coef_overrides),
json.dumps(node_values), json.dumps(actual_moves), activation.get("score"),
json.dumps(drift_by_inst), analyzed_at,
body.market_event_id, body.template_id,
@@ -1004,7 +1007,7 @@ def analyze_event(body: AnalyzeRequest):
activation_score, drift_json, analyzed_at)
VALUES (?,?,?,?,?,?,?,?,?,?)
""", (
body.market_event_id, body.template_id, primary_inst,
body.market_event_id, body.template_id, all_instruments_csv,
json.dumps(inputs), json.dumps(body.coef_overrides),
json.dumps(node_values), json.dumps(actual_moves),
activation.get("score"),