diff --git a/backend/routers/causal_lab.py b/backend/routers/causal_lab.py index 234304a..ba235f6 100644 --- a/backend/routers/causal_lab.py +++ b/backend/routers/causal_lab.py @@ -1091,7 +1091,8 @@ def _build_graph_json_from_spec(spec: dict) -> dict: "formula": inp_id + " * {{" + coef_name + "}}", }) edges.append({"from": inp_id, "to": inter_id, - "sign": "positive" if coef_val >= 0 else "negative", "style": "solid"}) + "sign": "positive" if coef_val >= 0 else "negative", "style": "solid", + "lag_days": 3}) # Nœuds de sortie — étalés horizontalement en bas inter_ids = [n["id"] for n in intermediates] @@ -1115,7 +1116,8 @@ def _build_graph_json_from_spec(spec: dict) -> dict: "formula": from_id + " * {{" + coef_name + "}}", }) edges.append({"from": from_id, "to": out_id, - "sign": "positive" if coef_val >= 0 else "negative", "style": "solid"}) + "sign": "positive" if coef_val >= 0 else "negative", "style": "solid", + "lag_days": 3}) instruments = list({out.get("instrument", "EURUSD") for out in outputs}) return { @@ -1252,6 +1254,8 @@ def _run_auto_analysis(event: dict, template_id: int) -> bool: # Effective lag from template edges (for price window and chip width) edges = graph.get("edges", []) effective_lag_days = max((e.get("lag_days", 0) or 0 for e in edges), default=0) + if effective_lag_days == 0: + effective_lag_days = 5 # Default: measure close-to-close impact over 5 trading days # Fetch actual prices to compute actual pips for scoring actual_moves: dict = {}