Commodity prices: Gas TTF, CO2 EUA, Coal API2, EUR/USD, marginal costs.
get_commodity_kpis
async
get_commodity_kpis(request: Request, response: Response)
Latest non-null value and change vs prior non-null per commodity.
Per-column query so a stale tail in one series (e.g. days of NULL
while the source feed lags) doesn't suppress the others.
Source code in dashboard/backend/app/routers/commodities.py
| @router.get("/kpi")
async def get_commodity_kpis(request: Request, response: Response):
"""Latest non-null value and change vs prior non-null per commodity.
Per-column query so a stale tail in one series (e.g. days of NULL
while the source feed lags) doesn't suppress the others.
"""
engine = request.app.state.engine
kpis = await run_in_threadpool(_get_commodity_kpis_sync, engine)
# KPI is always "latest" → short cache.
response.headers["Cache-Control"] = "public, max-age=300"
return kpis
|