feat: VaR/PnL schedulers + snapshots DB + page sur bouton

Backend:
- Tables var_snapshots + pnl_snapshots dans SQLite (contexte macro + prix tickers)
- var_service.py : save_var_snapshot, save_pnl_snapshot + fonctions get_*
- var_scheduler.py : threads APScheduler pour VaR (défaut 6h) et PnL (défaut 1h)
- router var.py : /run-now (POST compute+save), /latest, /snapshots, /pnl/run-now,
  /pnl/latest, /scheduler/status, /scheduler/config
- main.py : démarrage des deux schedulers au startup

Frontend:
- VaRAnalysis.tsx : plus d'auto-fetch ; charge le dernier snapshot DB au mount ;
  bouton "Calculer" → POST /run-now ; erreur backend = message clair ; historique
  de snapshots sélectionnables
- Config.tsx : section "Schedulers VaR & PnL" dans l'onglet cycle avec toggle
  enable/disable, intervalle, et boutons "Snapshot maintenant"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-20 06:21:20 +02:00
parent d64d1029bf
commit b4f3089c58
7 changed files with 1014 additions and 394 deletions

View File

@@ -75,12 +75,19 @@ def startup():
# Start auto-cycle scheduler if enabled
from services.auto_cycle import start_scheduler
start_scheduler()
# Start VaR + PnL snapshot schedulers
from services.var_scheduler import start_var_scheduler, start_pnl_scheduler
start_var_scheduler()
start_pnl_scheduler()
@app.on_event("shutdown")
def shutdown():
from services.auto_cycle import stop_scheduler
stop_scheduler()
from services.var_scheduler import stop_var_scheduler, stop_pnl_scheduler
stop_var_scheduler()
stop_pnl_scheduler()
app.include_router(market_data.router)