feat: instrument model
This commit is contained in:
@@ -1112,6 +1112,7 @@ def simulate_timeline(
|
||||
while cur <= today:
|
||||
# Accumule les events virtuels (What-if) actifs ce jour
|
||||
ev_by_cat: dict[str, float] = {}
|
||||
active_events_detail: list[dict] = []
|
||||
for ev in events:
|
||||
if ev["ev_date"] > cur:
|
||||
continue
|
||||
@@ -1123,8 +1124,17 @@ def simulate_timeline(
|
||||
df = _lifecycle(days, ev["rise"], ev["plateau"], ev["absorption"], ev["dtype"])
|
||||
if df < 0.01:
|
||||
continue
|
||||
cat = ev["category"]
|
||||
ev_by_cat[cat] = ev_by_cat.get(cat, 0.0) + round(ev["pips"] * df, 2)
|
||||
cat = ev["category"]
|
||||
contribution = round(ev["pips"] * df, 2)
|
||||
ev_by_cat[cat] = ev_by_cat.get(cat, 0.0) + contribution
|
||||
active_events_detail.append({
|
||||
"label": ev["label"],
|
||||
"pips": ev["pips"],
|
||||
"lifecycle_factor": round(df, 3),
|
||||
"contribution": contribution,
|
||||
"date": str(ev["ev_date"]),
|
||||
"category": cat,
|
||||
})
|
||||
|
||||
if ev_by_cat:
|
||||
# Des events virtuels sont actifs → recalcul complet avec régime
|
||||
@@ -1149,6 +1159,7 @@ def simulate_timeline(
|
||||
"synthetic_price": round(price_intercept + start_offset + net * pip_to_price, 6),
|
||||
"regime": regime_label,
|
||||
"nodes": {k: round(float(v), 1) for k, v in vals.items()},
|
||||
"active_events": active_events_detail,
|
||||
})
|
||||
cur += timedelta(days=1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user