feat: instrument model

This commit is contained in:
OpenSquared
2026-07-03 10:36:52 +02:00
parent c3e9b21bda
commit 5381b3fb92
2 changed files with 30 additions and 2 deletions

View File

@@ -200,8 +200,11 @@ def get_instrument_timeline(
"""Simulation jour par jour de tous les nœuds du modèle sur la période."""
from services.database import get_conn
from services.instrument_models import simulate_timeline
from services.price_history import get_price_history
conn = get_conn()
try:
# Pré-peupler le cache prix pour que l'auto-anchor ait les données disponibles
get_price_history(conn, instrument.upper(), period)
data = simulate_timeline(conn, instrument.upper(), period)
if not data:
raise HTTPException(status_code=404, detail=f"Modèle introuvable pour {instrument.upper()}")
@@ -218,8 +221,11 @@ def timeline_whatif(
"""Simulation what-if avec events virtuels injectés dans la timeline."""
from services.database import get_conn
from services.instrument_models import simulate_timeline
from services.price_history import get_price_history
conn = get_conn()
try:
# Garantir que le cache prix est disponible pour l'auto-anchor
get_price_history(conn, instrument.upper(), body.period)
ve_list = [ve.dict() for ve in body.virtual_events]
data = simulate_timeline(conn, instrument.upper(), body.period, virtual_events=ve_list)
if not data: